The word “Optional” by definition means available to be chosen, but not obligatory.

What does this mean in programming?

In programming languages and type theory, an option type or maybe type is a polymorphic type that represents encapsulation of an optional value; e.g., it is used as the return type of functions which may or may not return a meaningful value when they are applied.

So the question that comes to mind is What is Swift Optional? Is it a concept, behavior or something else? The answer is that it’s a data type!

Let’s read this line of code

Image for post
Image for post

When reading this line, someone would say that its type is a String, another would say it’s a String but Optional but that’s not correct. …


Fadi Ossama

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store