Skip to content

Commit 4adad78

Browse files
authored
Merge pull request #2807 from perl6/Enumeration-Int-method
Document Enumeration.Int Refs #2632. Thanks!
2 parents 820936b + 619fa6a commit 4adad78

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

doc/Type/Enumeration.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ Defined as:
167167
=for code :preamble<enum Norse-gods <Þor Oðin Freija>;>
168168
say Oðin.succ; # OUTPUT: «Freija␤»
169169
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+
170187
=head2 method C<===>
171188
172189
Defined as

0 commit comments

Comments
 (0)