Scala¶
Option¶
An Option ins scala represents a value that may or may not exist. It has two possible forms. Some(value) — a value exists. None — no value exists.
Instead of returning null, Scala code often uses Option to make the absence of a value explicit. Common usage
You can also safely transform an Option with methods like map, getOrElse, and flatMap: