Working with swift optionals?

Example:


  var name: String? = "John"
  print(name)  // Outputs: Optional("John")
  

Solution:

You can use if let or guard to safely unwrap the optional value.

Beginner's Guide to Swift