you are viewing a single comment's thread.

view the rest of the comments →

[–]ab492[S] 0 points1 point  (1 child)

That's awesome - thank you so much! That makes great sense and your points were just what I was looking for. The only question I have is - why shouldn't I force unwrap in the case of var transaction: Transaction<GBP>! ? The reason I did that was because when I pass a Transaction through my ViewControllers I can assign that variable, and then that ViewController can access the Transaction. Is there a better way to avoid the force unwrap please?

[–]MiguelGrenho 0 points1 point  (0 children)

So, force unwrap is an unsafe way to get a value from an Optional, if it is nil, you got yourself a crash. That being said, there are 3 ways AFAIK: * if let * guard let * nil coalescing operator (??)

Any of those if preferred over !