Swift | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Swift

Hello, can someone tell me what is code for input since I couldnt find myself? I need to enter something in program but I dont know what is the input code. Is it same as in objective c or? Thank you

14th Jan 2019, 1:27 PM
Xneva87
Xneva87 - avatar
4 Answers
+ 2
let var = readLine() readLine returns an optional string. When calling it print ex. print(varname!) , include the ! to refrain it from being an optional. If you dont it will say optional(“valueofvar”) Hope this helps
14th Jan 2019, 1:44 PM
Joery De Loose
Joery De Loose - avatar
+ 2
In comparison to other languages like C# and java it’s kind of similar, C++ is special, also is considered a high level language, swift not so much
14th Jan 2019, 8:51 PM
Joery De Loose
Joery De Loose - avatar
+ 1
Thats a bit confusing I mean thanks for the explanation, but I still dont get it. Why is input so complicated in Swift, C++ is harder than swift and all what you have to do is to type cin>> and then you do input from the keyboard.
14th Jan 2019, 8:44 PM
Xneva87
Xneva87 - avatar
+ 1
Is it not in the tutorial?
23rd Dec 2020, 12:52 PM
Sonic
Sonic - avatar