Re: Correct enum incantation?

2021-05-05 Thread Fernando Santagata
On Wed, May 5, 2021 at 6:00 PM William Michels via perl6-users <
perl6-us...@perl.org> wrote:

> Hello,
>
> I've been reading over an interesting Answer on StackOverflow by wamba:
>
> https://stackoverflow.com/a/67324175/7270649
>
> I started trying to explore enums on my own and quickly realized that
> method calls on enums are different from simple key/value pairs. For enums,
> calling a `.key` or `.value` or `.kv` method won't work. Instead one must
> use something like `.^enum_values` or `.^enum_value_list`.
>

Probably you need the new and shiny compiler ;)

> $*RAKU.compiler.version
v2021.04
> Month.keys
(oct dec aug jun mar apr feb nov jul may sep jan)
> Month.values
(11 6 9 2 5 7 3 12 8 4 10 1)
> .say for Month.kv
nov
11
jul
7
sep
9
jan
1
oct
10
mar
3
jun
6
apr
4
aug
8
dec
12
feb
2
may
5
-- 
Fernando Santagata


Re: Correct enum incantation?

2021-05-05 Thread William Michels via perl6-language
Thank you Fernando!

(still on Rakudo 2020.10 here).

On Wed, May 5, 2021 at 10:24 AM Fernando Santagata <
nando.santag...@gmail.com> wrote:

> On Wed, May 5, 2021 at 6:00 PM William Michels via perl6-users <
> perl6-us...@perl.org> wrote:
>
>> Hello,
>>
>> I've been reading over an interesting Answer on StackOverflow by wamba:
>>
>> https://stackoverflow.com/a/67324175/7270649
>>
>> I started trying to explore enums on my own and quickly realized that
>> method calls on enums are different from simple key/value pairs. For enums,
>> calling a `.key` or `.value` or `.kv` method won't work. Instead one must
>> use something like `.^enum_values` or `.^enum_value_list`.
>>
>
> Probably you need the new and shiny compiler ;)
>
> > $*RAKU.compiler.version
> v2021.04
> > Month.keys
> (oct dec aug jun mar apr feb nov jul may sep jan)
> > Month.values
> (11 6 9 2 5 7 3 12 8 4 10 1)
> > .say for Month.kv
> nov
> 11
> jul
> 7
> sep
> 9
> jan
> 1
> oct
> 10
> mar
> 3
> jun
> 6
> apr
> 4
> aug
> 8
> dec
> 12
> feb
> 2
> may
> 5
> --
> Fernando Santagata
>