casualjim
12/6/2011 - 4:22 PM

gistfile1.txt

scala> def test(a: Any) = a match {
     | case _ : Unit => "Unit"
     | case _ => "Other"
     | }
test: (a: Any)java.lang.String

scala> test(())
res1: java.lang.String = Unit

scala> test(println("hello"))
hello
res2: java.lang.String = Unit

scala> test(Unit)
res3: java.lang.String = Other

scala> def test(a: Any) = a match {
     | case _: Unit | Unit => "Unit"
     | case _ => "Other"
     | }
test: (a: Any)java.lang.String

scala> test(Unit)
res4: java.lang.String = Unit