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.
01:41 habere-et-disper left 02:17 teatime left 02:18 teatime joined 02:29 teatwo joined 02:33 teatime left
CIAvash m: sub pear ((:$key, :$value)) { say $key ~ ' => ' ~ $value }; say pear( 3 => 4 ); # @habere-et-disper:libera.chat 05:43
camelia 3 => 4
True
07:08 kjp left 07:11 kjp joined
librasteve m: sub pear ( Pair $p ) { say .key ~ ' => ' ~ .value given $p }; say pear( 3 => 4 ); 07:44
Raku eval 3 => 4 True
librasteve m: sub pear { say .key ~ ' => ' ~ .value given $^p }; say pear( 3 => 4 ); 07:50
Raku eval 3 => 4 True
librasteve ^^ but neither really does what you asked ;-( 07:51
08:00 dakkar joined
avuserow m: sub pear(Pair $_) { say "{.key} => {.value}" }; pear(3 => 4) 13:46
camelia 3 => 4
lizmat m: sub pear(Pair $_) { say "{.key} => {.value}" }; pear(a => 4) 13:50
camelia Too few positionals passed; expected 1 argument but got 0
in sub pear at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat one of the reasons I think named arguments should always be specified with the colonpair syntax 13:51
avuserow Yeah I see what you mean. I've run into a few issues with trying to pass Pairs positionally. 14:03
Nemokosch the colonpair syntax wouldn't help with this 14:05
m: sub pear(Pair $_) { say "{.key} => {.value}" }; pear (a => 4)
Raku eval a => 4
Nemokosch no matter how funny it seems, the extra space does help with it 14:06
avuserow m: sub pear(Pair $_) { say "{.key} => {.value}" }; pear((a => 4))
camelia a => 4
lizmat Nemokosch that's fatarrow syntax, :a(4) would be colonpair syntax
avuserow It's the parens around the Pair that forces it to be positional.
Nemokosch yes, I know. And both syntaxes are treated the same way. 14:07
and that's only right actually
lizmat right, except 3 => 4 is *not* treated as a named, while it still is fatarrow syntax
Nemokosch 3 => 4 is conceptually bizarre. The name "pair" doesn't properly hint that this type isn't meant for things like that 14:09
14:14 teatwo left 14:15 teatwo joined 14:18 teatwo left, teatwo joined 15:17 razetime joined 16:38 dakkar left 17:21 razetime left 18:28 KOTP left 18:31 KOTP joined