The method values on enums returns an Array that gets allocated at each call. This is inline with how Java enums work.
It would be nice if an alternative method existed, for example called seq, that returned an ArraySeq that is just a shared immutable reference to the already allocated sequence of values, not requiring a defensive copying. This would be more efficient and also more Scala-idomatic.
The method
values
on enums returns anArray
that gets allocated at each call. This is inline with how Java enums work.It would be nice if an alternative method existed, for example called
seq
, that returned anArraySeq
that is just a shared immutable reference to the already allocated sequence of values, not requiring a defensive copying. This would be more efficient and also more Scala-idomatic.