Skip to content

Conversation

@samlev
Copy link
Contributor

@samlev samlev commented Mar 12, 2022

This extends the Enum traits to also work in a meaninful manner with "Pure" enums, as well as Backed Enums.

A couple of the methods kind of "repeat" functionality, but this makes pure enums as useful as string-backed enums, where the string value is equivalent to the case name.

Altered `::values()` to act like `::names()` for backed enums, code style fixes, general cleanups
@samlev samlev force-pushed the feature/pureEnums branch from 01bb019 to dea16e4 Compare March 14, 2022 21:35
@stancl stancl mentioned this pull request Mar 15, 2022
### Options

This helper returns an associative array of case names and values.
This helper returns an associative array of case names and values for backed enums, or a list of names for pure enums (making this functionally equivalent to [`::names()`](#names) for pure Enums).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll merge this now, but just want to confirm: for pure enums, we're using names for everything, right?

Meaning, names, values, options all return the names. And the internal indices aren't used for anything.

@stancl stancl merged commit 0c87357 into archtechx:master Mar 23, 2022
@samlev samlev deleted the feature/pureEnums branch March 23, 2022 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants