Re: Correct enum incantation?

[email protected] (William Michels via perl6-language) Wed, 5 May 2021 10:52:18 -0700
Newsgroups perl.perl6.language
Message-ID <CAA99HCysGJ7O9BokZ+W0v=zm5c3b=zOm_v+dnv8yBV4bQ1LqnQ@mail.gmail.com>
--0000000000003b242f05c198ddc4
Content-Type: text/plain; charset="UTF-8"

Thank you Fernando!

(still on Rakudo 2020.10 here).

On Wed, May 5, 2021 at 10:24 AM Fernando Santagata <
[email protected]> wrote:

> On Wed, May 5, 2021 at 6:00 PM William Michels via perl6-users <
> [email protected]> 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
>

--0000000000003b242f05c198ddc4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Thank you Fernando! <br></div><div><br></div><div>(st=
ill on Rakudo 2020.10 here).<br></div></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Wed, May 5, 2021 at 10:24 AM Ferna=
ndo Santagata &lt;<a href=3D"mailto:[email protected]" target=3D"_b=
lank">[email protected]</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_quote=
"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, May 5, 2021 at 6:00 PM Will=
iam Michels via perl6-users &lt;<a href=3D"mailto:[email protected]" tar=
get=3D"_blank">[email protected]</a>&gt; wrote:<br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hello,<br><br>I&#39;ve =
been reading over an interesting Answer on StackOverflow by wamba:<br><br><=
a href=3D"https://stackoverflow.com/a/67324175/7270649" target=3D"_blank">h=
ttps://stackoverflow.com/a/67324175/7270649</a><br><br>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 `.va=
lue` or `.kv` method won&#39;t work. Instead one must use something like `.=
^enum_values` or `.^enum_value_list`.<br></div></blockquote><div><br></div>=
<div><div style=3D"color:rgb(0,0,0)" class=3D"gmail_default">Probably you n=
eed the new and shiny compiler ;)</div><br></div><div><div style=3D"color:r=
gb(0,0,0)" class=3D"gmail_default"><span class=3D"gmail_default" style=3D"c=
olor:rgb(0,0,0)"></span>&gt; $*RAKU.compiler.version<br><div class=3D"gmail=
_quote"><div>v2021.04</div></div></div></div><div>&gt; Month.keys<br>(oct d=
ec aug jun mar apr feb nov jul may sep jan)</div><div><div style=3D"color:r=
gb(0,0,0)" class=3D"gmail_default">&gt; Month.values<br></div>(11 6 9 2 5 7=
 3 12 8 4 10 1)<br>&gt; .say for Month.kv<br>nov<br>11<br>jul<br>7<br>sep<b=
r>9<br>jan<br>1<br>oct<br>10<br>mar<br>3<br>jun<br>6<br>apr<br>4<br>aug<br>=
8<br>dec<br>12<br>feb<br>2<br>may<br>5<br></div><div><span class=3D"gmail_d=
efault" style=3D"color:rgb(0,0,0)"></span></div></div>-- <br><div dir=3D"lt=
r">Fernando Santagata</div></div>
</blockquote></div>

--0000000000003b242f05c198ddc4--