+ 1

How to ask for input in Swift?

How can I ask for a user to input something in Swift? Like cin in C++

27th Jul 2018, 11:19 PM
Carlos DV
Carlos DV - avatar
4 odpowiedzi
+ 2
Try this: let name = readLine() print("Your name is \(name!).")
28th Jul 2018, 1:28 AM
Mickel
Mickel - avatar
+ 1
That's weird, in my case it worked without problems.
28th Jul 2018, 3:17 AM
Mickel
Mickel - avatar
0
Almost works, readLine() is asking for input, but name is kept as nil.
28th Jul 2018, 3:15 AM
Carlos DV
Carlos DV - avatar
0
Could you please post a link to a playground code using this? I could be overlooking something.
28th Jul 2018, 6:53 PM
Carlos DV
Carlos DV - avatar