scala> def nextOption = if (util.Random.nextInt > 0) Some(1) else None
nextOption: Option[Int]
scala> nextOption
res1: Option[Int] = Some(1)
scala> nextOption
res3: Option[Int] = None
Trying to learn scala, few questions following the code executed above:
1. Is the right part of nextOption definition consideret a function literal?
2. Would that change if it was defined using 'val' keyword instead of 'def'.
3. Why is nextOption type an Option[Int] and not a function? ( ()=>Option[Int] )
4. Would adding parantesses or brackets to this code change its type/value?
5. What would be the difference between nextOption and something like '() => if (......) some(1) Else None'