Skip to content
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

Enum#member_name should be exposed as public API #15279

Open
straight-shoota opened this issue Dec 14, 2024 · 0 comments
Open

Enum#member_name should be exposed as public API #15279

straight-shoota opened this issue Dec 14, 2024 · 0 comments

Comments

@straight-shoota
Copy link
Member

straight-shoota commented Dec 14, 2024

Enum#member_name is an internal helper method that returns the name of the enum member, or nil if it's an unnamed member.
I'd like to expose this method as part of the public API because it could be valuable for other use cases.

One example is Process::Status#to_s which relies on Enum#to_s if the status is a signal exit. Enum#to_s returns the name of the member, or the numerical representation if unnamed. A number however would be indistinguishable from the exit code of a normal exit. So for Process::Status#to_s we want to use the member name if available and otherwise use the unambiguous stringification from Enum#to_s (see #15280).

I'm sure there are other use cases as well. Additionally, this serves as a simple indication whether the enum member is named or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant