From 3e13d0e00c0ec68bea7ee5e23a5eb4934ba32683 Mon Sep 17 00:00:00 2001 From: George Dietrich Date: Mon, 26 Sep 2022 08:34:09 -0400 Subject: [PATCH] Document how to change base type of an enum (#9803) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johannes Müller --- src/enum.cr | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/enum.cr b/src/enum.cr index 0f2fd022e0cf..c3438d7812dd 100644 --- a/src/enum.cr +++ b/src/enum.cr @@ -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)