We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Extracted from #7629. Reopening doesn't work, but inheriting may do. I have a use-case described in the mentioned issue.
enum Foo Bar end enum Qux < Foo Baz end pp Qux.values # => [Qux::Bar, Qux::Baz]
Also:
def handle(foo : Foo) end def handle(qux : Qux) if qux.bar? handle(qux.as(Foo)) # Maybe another syntax, but you get the idea else # ... end end
#6653 (though I still don't have a usecase for this 😆):
abstract enum Foo Bar end enum Qux < Foo end pp Qux.values # => [Qux::Bar] enum Quux < Foo Baz end pp Quux.values # => [Quux::Bar, Quux::Baz] def handle(foo : Foo) if foo.bar? end end
The text was updated successfully, but these errors were encountered:
I've found this related comment https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/types.cr#L2634 # enum Foo < Enum(Int32)
# enum Foo < Enum(Int32)
Sorry, something went wrong.
I don't see how the concept of inheritance fits with enums. Is there any good use case for this?
I'd suggest to close this.
There is still this TODO, what's planned about it?
That's an implementation detail.
No branches or pull requests
Extracted from #7629. Reopening doesn't work, but inheriting may do. I have a use-case described in the mentioned issue.
Also:
Also
#6653 (though I still don't have a usecase for this 😆):
The text was updated successfully, but these errors were encountered: