Scala's Option object

Scala Option (option) type is used to indicate that a value is optional (valued or no value), in fact, the main purpose is because Scala does not recommend that we directly use null to identify an empty data

In Scala, it is considered bad to use null directly, so the Option object appears

For example, Option[T] is a container of optional values ​​of type T

When we call the method to get a value, if the value exists, Option[T] will return a result of Some[T]. If it does not exist, Option[T] will return a result of None.

Guess you like

Origin blog.csdn.net/dudadudadd/article/details/114374730