Why is the values method on enum an Array? Could it be an immutable ArraySeq?

On the topic of the previously mentioned EnumValueSet, just a reminder that Enumeration.ValueSet is already part of the stdlib :smile:

:eyes:

Aha thanks! How to use it? (Can’t find examples in doc)

right but its for the old scala.Enumeration

1 Like

Even within the domain of ā€œold Enumerationā€, ValueSet had problems (with inference).

Oh, maybe that was fixed in 2.13.

In any case, it may explain a judicious lack of documentation.

1 Like

Aha! Thanks. I had forgotten (or repressed) that thing. So I guess @JD557 meant that there is precedence for (supposed to be) ā€œniceā€ values …

Yes, sorry. That’s what I meant (not that you could use this to solve your issue).

1 Like

So why did Scala 3 give up on a very sensible concept and proper domain modeling and instead decided to went back to stone age and just spits out a useless Java array?

This old ValueSet* implementation had even one of the features that are imho super important: You could get BitSets out of enum values! That’s vital for native interop (with languages like C++).


* I knew that I’ve seen this somewhere in the past, but I thought it was actually part of the Java API. But I couldn’t find it there as I’ve looked when the discussion started here. But the scala.Enumeration, which nobody ever used, including me, was the source. D’oh! Thanks to @JD557 for pointing that out.

1 Like