In Scala, Option is used to represent optional values that is either exist or not exist and Option is an abstract class. Option has two subclasses:
1.Some and
2.None.
All three (Option, Some and None) are defined in “scala” package like “scala.Option”.Option is a bounded collection in Scala,which contains either zero or one element. If Option contains zero elements that is None. If Option contains one element, that is Some.
Some is used to represent existing value. None is used to represent non-existent value.Example:-
def get(val index: Int): Option[String]
Let us assume that this method is from List. This method has a return type of Option[String]. If List contains elements, this get method returns “Some[String]” element available in that index position. Otherwise, it returns “None” (that is no elements)Some is a case class and None is an Object. As both are case class/object, we can use them in Pattern Matching very well.The combination of all these three definitions is known as Option/Some/None Design Pattern in Scala.