readLine () | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

readLine ()

Hi all! I have some Questions see code : 1. if input is Hello results are : English:Optional("Hello") Alien:Optional("olleH") But Why are Optionals there??? 2. Input leaving empty --> Result are: English:Optional("") Alien:Optional("") why Else Condition doesn't work??? 3. see line : var Output:String? = String(Input!.reversed()). It is working only if I Add "!" after Input. but Theoretically it it already wrapped up ? isn't it? Tank you ! J. CODE: var Input:String? = readLine() if let ActualInput = Input { print("English:\(Input)") }else { ("no solution") } var Output:String? = String(Input!.reversed()). if let ActualOutput = Output{ print ("Alien:\(Output)") }else { print ("no solution") } results: Why are Optionals there??? English:Optional("Hello") Alien:Optional("olleH")

21st Apr 2020, 11:28 AM
Johny Bravo 123
Johny Bravo 123 - avatar
1 Answer
0
i solved it :)
23rd Apr 2020, 6:59 PM
Johny Bravo 123
Johny Bravo 123 - avatar