« Return to Thread: [scala] Confusion about Unit

[scala] Confusion about Unit

by Alan Wood-2 :: Rate this Message:

Reply to Author | View in Thread

I'm confused about Unit. It seems that any type conforms to it even though it's populated by a single value? ...

scala> var a : Int = 24
a: Int = 24

scala> var u : Unit = ()
u: Unit = ()

scala> a = u
<console>:6: error: type mismatch;
 found   : Unit
 required: Int
       a = u
           ^

scala> u = a
u: Unit = ()

----
Alan

 « Return to Thread: [scala] Confusion about Unit