I just read about case sequence as partial functions and the syntax is a little bit strange.
For example
def test: Int => Int = {
case 1 => 2
case 2 => 3
case _ => 0
}
I would expect that test has no arguments and would return a function of type Int => Int
But after some testing it seems that it takes an int as an argument and returns an int, so I rewrote it to…
def test1(i: Int): Int =
i match {
case 1 => 2
case 2 => 3
case _ => 0
}
Are test and test1 equal?
The former code does return a function of type Int => Int.
Perhaps what is confusing is that apply can be called directly: