Add enum class and nested enumeration example#109
Merged
BowenFu merged 2 commits intoBowenFu:mainfrom Dec 31, 2025
Merged
Conversation
Owner
|
@jahan-addison Thanks for adding the sample. Regarding nested example, there could be two cases, 1) both values are independent, 2) the second value is dependent on how the first one is matched. For the first case, the codes could be more concise like return m::match(os_type, arch_type)(
m::pattern | m:: ds(OS_Type:: Linux, Arch_Type::ARM64) = 2,
m::pattern | m::ds(OS_Type:: Linux, Arch_Type:: X8664) = 5,
m::pattern | m::ds(OS_Type::BSD, Arch_Type:: X8664) = 4,
m::pattern | m::_ = 1);For the second case, the nested version could be more valuable. |
Contributor
Author
|
Nice, I'll add both; in my case the values were dependent, but independent is another use case too |
Owner
|
Thank you Jahan. I just merged it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I could not find an enum class and nested enum example to replace a nested switch case on enums.
matchitwas very helpful in enumerating complicated nested cases