+4

Does the Swift tutorial here not have a section on getting console user input?

Is it not possible to get console user input in Swift?

2/21/2020 11:31:51 PM

Sonic

9 Answers

New Answer

+5

for strings try this: let n = readLine()! print(n) for integers try this: let n = Int(readLine()!)! print(n)

+4

Sonic and Kylie Scott here is a quick code https://code.sololearn.com/ciP7ZE1X6VF3/?ref=app

+4

Yes I just reviewed that the input lesson was not available... strange but true unless I missed it. Generally yes the app is usually complete and laid out.

+3

Google tells me to use readLine()

+3

ive been having this issue as well, ive used readline but then the compiler would yell at me when i try to manipulate or do whatever with the input

+2

BroFar thanks.

+2

Alexandr thanks. What do the exclamation marks do after readLine()! and Int()! ?

+2

Sonic without the exclamation it will display optional in the console

+2

Am I right in observing that this information is not available in the Sololearn Swift tutorial? Is it because console user input is not a major part of Swift?