+ 1
Handling user inputs
Started learning Swift and wanted to practice by solving code coach challenges, but I'm having troubles converting user inputs to arrays. https://code.sololearn.com/c3I42NMhIJvJ/?ref=app
3 Respostas
+ 1
in the second case, since you got the string from the user, you need to unwrap the value. Do it like word!.characters.split etc... add an ! aftet word and it works.
+ 1
well, the user input can be nil. So swift wraps the input into an Optional String type and not String. In swift, every Optional String should be unwrapped either with an ? or an ! before being used to get the actual value. Unwrapping makes sure the value is not nil.
0
George Samanlian thanks.
Could you explain what unwrapping does