We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3bbea96 commit 619fa6aCopy full SHA for 619fa6a
doc/Type/Enumeration.pod6
@@ -167,6 +167,23 @@ Defined as:
167
=for code :preamble<enum Norse-gods <Þor Oðin Freija>;>
168
say Oðin.succ; # OUTPUT: «Freija»
169
170
+=head2 method Int
171
+
172
+Defined as:
173
174
+ multi method Int(::?CLASS:D:)
175
176
+Takes a value of an enum and returns it after coercion to C<Int>:
177
178
+ enum Numbers <One Two Three>;
179
+ say Two.Int; # OUTPUT: «1»
180
+ enum Numbers ( cool => '42', almost-pi => '3' )
181
+ say cool.Int; # OUTPUT: «42»
182
+ say almost-pi.Int; # OUTPUT: «3»
183
184
+Note that if the value cannot be coerced to C<Int>, an exception will
185
+be thrown.
186
187
=head2 method C<===>
188
189
Defined as
0 commit comments