-
-
Notifications
You must be signed in to change notification settings - Fork 132
Static method to get array of all enum instances #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, this is indeed something I've never thought of, and never needed. But it makes sense, I can imagine plenty of scenarios where you would want to get the list of the actual enum instances… I think if you make a PR I'd be +1 to merge it, if anybody else has a preference please voice it. And yes, now I wish |
We could break BC and release it as 2.0... ;-) |
No that's not the goal. As I said if the new method name is |
Add static values() method to return array of all Enum instances (fixes #18)
I have tagged v1.4.0 |
Thanks! |
When using this library, I was slightly surprised to find that the toArray() method returns an associative array mapping the enum constant names to their underlying values, rather than to instances of the enum object wrapping the value. When adding additional behavior to the enum via instance methods, having the enum objects is often more useful than only the underlying constant values.
What do you think of adding a static method, e.g. getInstances(), returning an array mapping constant names to object instances?
The text was updated successfully, but these errors were encountered: