Priya Talreja avatar

Chapter 7 - Swift Optionals

priyatalreja

Published: 25 May 2018 › Updated: 25 May 2018Chapter 7 - Swift Optionals

Chapter 7 - Swift Optionals

  • Swift is a very safe language. It works hard to ensure your code never fails in surprising ways.
  • Optionals are a powerful feature in Swift language which come to solve the problem of non-existing values. Optionals are a powerful feature in Swift language which come to solve the problem of non-existing values.
  • An optional represents two possibilities: Either there is a value, and you can unwrap the optional to access that value, or there isn’t a value at all.

Swift Tutorials Priya Talreja

  • The question mark indicates that the value it contains is optional, meaning that it might contain some Int value, or it might contain no value at all.
  • The Exclamation mark (!) indicates that we are sure that the variable contains some value. It is called force unwrapping.
  • A good practice is to check for nil before unwrapping.
My next blog will be on Types of Data.

Priya Talreja Xcode Tutorials
Please let me know if you have any doubts or queries in the comment section below.
Follow me priyatalreja@priyatalreja to get the latest feeds of iOS App step by step development tutorials.
Thanks.

Leave Chapter 7 - Swift Optionals to:

Written by

Developer

Read more #swift posts


Best Posts From Priya Talreja

We have not curated any of priyatalreja's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Priya Talreja