readLine () | SoloLearn: Learn to code for FREE!

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")

4/21/2020 11:28:33 AM

János Bajári

1 Answer

New Answer

0

i solved it :)