Scala Option

Option is the way in Scala to handle null.

It allows to encapsulate the concept of “is this value defined” or “does this variable contains a value“.

You might have guessed it on your own but the isDefined method will return true when the Option contains a value, and isEmpty returns true when the Option contains nothing.

We are going to learn, in later SKB, aboutpattern matching and map. It will allow us to modify the value contained in the Option.

Reveal more information and clues
Load Exercise