As a developer, it would be nice to be able to natively iterate enum values.
for index, item in Enum.NormalId:GetEnumItems() do
I want to do
for index, item in Enum.NormalId do
This reduces visual complexity and makes it easier to parse what you’re reading.
Sorry, but we do not plan to implement this suggestion.
We can reconsider if this request gathers a lot of support from other developers.
Why not? Would implementing an __iter metatable break backwards compatibility?
Would be cool if you could define your own Enums instead of using some weird Array hack.
I would argue for consistency here.
GetEnumItems() is analogous to other frequently used methods such as
GetAttributes(). Being able to iterate over an Enum gives a it a false representation that it’s a table value.
It’s a very niche feature and it would probably go unnoticed, as it just replaces current functionality with
I would have thought that’s more down to the fact that there are multiple ways to iterate over those data types, but that’s a possible interpretation.
Reasonable take, but I argue that an implicit iterator doesn’t make sense for Instance since there are several sensible ways for it to work depending on the instance type. For example, iterating over a UIListLayout wouldn’t be useful for children at all but it would be very useful to make it do something completely unique, like iterating over the list elements in order. It would be a whole mess to do this across the board. Enums, on the other hand, can only be iterated in one sensible way: Iterating over the items in order. What it lacks in consistency it makes up for in sensibility.
Could a way to convert
Enum.Value back into an Enum with some sort of function be considered? At the moment the only way to do it is to set an Instance’s property then read said property as it gets converted.