[swift-users] get input from playground

Bee bee.ography at gmail.com
Mon Dec 7 02:41:44 CST 2015


Hi all,

I'd like to read keyboard input from playground console. Swift doc gives me
readLine function. I tried it on Playground but it didn't accept any input
I entered from the keyboard. Screenshot attached.

The code:
// — start code —
var name: String
print("What's your name? ", terminator: "")
name = readLine(stripNewline: true)!
print("Hello, \(name)... good to see you!")
// — end code —

Tried it on:
- Macbook Pro with OS X El Capitan
- XCode 7 with Swift 2

Any help please? Thank you.

-- 
-Bee-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151207/090be57e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: playground console input.png
Type: image/png
Size: 45440 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20151207/090be57e/attachment.png>


More information about the swift-users mailing list