case class Thing(n: Int)
def ThingCreator(c:Int): Thing =
{
val a = 10
val b = 20
c match {
case 0 => Thing(1)
case a => Thing(2)
case b => Thing(3)
case _ => Thing(4)
}
}
What would be the output if we call ThingCreator() with inputs ranging from 0 to 100?
The answer was given as Thing(1) and Thing(2)
but I don't get how it is not Thing(1) through Thing(4)
. If we pass 50 it should match the last case. Can someone explain how it works?