Learn about dictionaries in Swift 3.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4095-beginning-swift-3/lessons/12
Learn about dictionaries in Swift 3.
Hi!
There is a typo in the instructions on line 20. It says 53 should be 54.
Bob
Thanks for the heads up!
I may be wrong but, isn’t the entire point of Swift’s if let
statements to stop users from doing a != nil
? You only want to force unwrap a variable when you know for sure it is not nil. I noticed you did the != nil
syntax as well in the optionals video.
Hey Simon,
There are different ways to unwrap a variable. Just like the video, you only want to force unwrap a variable when you know the value is not nil. As you saw in the video he did an if statement to make sure the values did not contain nil values. If they were to contain nil values, the if statement wouldn’t run.
Ways to unwrap an optional.
Use ! - NOT RECOMMENDED, IF NIL VALUE YOUR APP WILL CRASH
Use an “If Let”
Use a “Guard Statement” - Typically used in methods/functions
Well put, andresaguero10!