![]() |
VOOZH | about |
GeeksForGeeksHere, method usingnull that consists a parameter of type Null, we can only pass two things. null itself or a reference of type Null. when we passed a string as argument it didn't work and generated an error.
1 2 3Here, method printNumber takes a parameter called num, which has a type of (Int) => Unit. This means that num is a method that consists a single parameter of type Int. method printNumber return type of Unit, which means num isn’t supposed to return a value.
List()Thus, we can see that an empty list is returned.
List()Here, an empty List is returned. Example : Output :
trueThus, we can say that None is empty as true is returned. Example : Output :
NoneHence, None can be converted to a String. Example : Output :
NoneFor more about this example see Scala's Option.