Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
@minnepicker THank you so much sensei!
hi bridgecoder, Swift has a concept called optionals. These are used when an object may or may not exist. For example, if I try to initialize a digit with a string that contains an Int (like this: Int("5")), everything is fine. However, if I try to use an invalid string (like this: Int("Cow")), Swift can't make an integer out of it so it returns nil. Because this initializer might return nil, it is optional. Swift can't make a comparison on an optional object. We have to "unwrap" it and see if a value exists or not. There are several ways to unwrap an optional in Swift. The least safe way is to force unwrap it using "!". The "!" in this context is basically saying that you guarantee the optional will have a value and not nil. If it doesn't have a value, your program will crash.
hey pal, Im new to swift, could you please explain this step: if Int("(digit)")! < 5
Especially what ! does? I come from Python bg so I tried using <= but didnt work so...Please do let me know
I chuckled when I saw this; very clever 😀