This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html
Set by lizmat on 8 June 2022.
00:29 frost joined 01:43 frost left
Nemokosch Lol 03:48
04:10 frost joined 07:58 jaguart joined 09:28 discord-raku-bot left, discord-raku-bot joined 13:20 jgaz joined 13:54 jaguart left
stevied ok, what's going on with this bit of code? 13:56
```
enum proc-options <one two three four>;
my @opt = qw<one two three four>;
for @opt -> $opt {
when !proc-options::{$opt} {
warn "'$opt' is not a valid option";
}
say $opt;
}
```
outputs:
```
'one' is not a valid option
in block at /Users/stevedondley/Library/Application Support/"Edument Central Europe"/Comma2022.06/scratches/random-scratch line 10
two
three
four
Kaiepi an untyped enum value defaults to 0 initially 14:34
Nemokosch What follows? 14:40
stevied I don't get it 14:41
why would it do that?
15:50 jgaz left 15:52 jgaz joined 16:24 jgaz left 16:49 deadmarshal left 16:59 deadmarshal joined 19:10 jaguart joined
CIAvash m: enum proc-options <one two three four>; say proc-options.enums.sort(*.value) 19:11
camelia (one => 0 two => 1 three => 2 four => 3)
CIAvash m: enum proc-options (one => 1, 'two', 'three', 'four'); say proc-options.enums.sort(*.value); 19:12
camelia (one => 1 two => 2 three => 3 four => 4)
CIAvash m: enum proc-options <one two three four>; say proc-options.enums<one>:exists 19:15
camelia True
Nemokosch Oooh 21:47
I guess we are idiots now
!proc-options::{$opt} did return a defined value: 0 21:48
Should have tested for existence, not truthiness