Why does this code crash the Scala 2.8.1 compiler?
val a = new Array[{ var x = 1 }](3)
Is it a compiler bug?
Anyway is it a legal Scala code? (I want an array of objects with anonymous class type)
Update:
What I want is something like:
class X { var x = 1}
val a = new Array[X](3)
but without having to define standalone X
Compiler crashes are always bugs. But why are you trying to set
x
equal to 1 in the type declaration?Your probably want one of these:
(and the compiler is happy with either of these).