what about `iterator()` on `Enum`s, so that we can...
# stdlib
e
what about
iterator()
on `Enum`s, so that we can write
for(e in enum)
? Instead of
e in enum.values()
which, I guess, implies an array copy?
m
There's no safe way to iterate enum elements without copying.
(
sun.misc.SharedSecrets
is not a safe way :)
e
I didnt know that, thanks for sharing it, Mike!
anyway, if an enum is supposed to be immutable, why dont expose it?
m
Arrays cannot be immutable on the JVM. I think returning
$VALUES.clone()
was a mistake, and it should be
public static final Set<Self> VALUES = unmodifiableSet(EnumSet.allOf(Self.class))
instead.
2