FunctionalProgrammingSimplified
FunctionalProgrammingSimplified copied to clipboard
page 163: side effect and return type is Unit
val evenOrOdd = i match {
case 1 | 3 | 5 | 7 | 9 => println("odd")
case 2 | 4 | 6 | 8 | 10 => println("even")
}
I think this should just be:
val evenOrOdd = i match {
case 1 | 3 | 5 | 7 | 9 => "odd"
case 2 | 4 | 6 | 8 | 10 => "even"
}
If not the type of val evenOrOdd is Unit