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

Document how to change base type of an enum #9803

Merged
14 changes: 14 additions & 0 deletions src/enum.cr
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@
# puts "Got blue"
# end
# ```
#
# ### Changing the Base Type
#
# The type of the underlying enum value is `Int32` by default, but it can be changed to any type in `Int::Primitive`.
#
# ```
# enum Color : UInt8
# Red
# Green
# Blue
# end
#
# Color::Red.value # : UInt8
# ```
struct Enum
include Comparable(self)

Expand Down