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:18 stanrifkin left 01:05 Manifest0 left 02:34 MasterDuke joined
Nahita DarthGandalf: hi, my original message was my @a = [[12, 3], [4, 5]]; @a.splice(1, 0, [@a[1].clone,]); @a[1][2]++; say @a; the essence of it is passing [@stuff,] with comma-trailed to splice. clone is so it's not shared, and ++ is to prove it's not shared 08:00
trailing comma is needed because otherwise [...] calls .Array, on ... (even if it doesn't explicitly call it, the end effect is the same from what I have seen) 08:06
it's kind of surprising actually, i stumbled upon this recently:
m: [%(3, 4, 5, 6)].raku.say 08:07
Raku eval ["3" => 4, "5" => 6]
Nahita isn't a 1-length array with the Hash, rather the Hash is spread to its pairs 08:08
therefore, like in the bare parens case with 1 elem in it ($thing,) where "," must be there, in square brackets, for predictability for amateurs like me, "," must be there as well unless other interpretation is specifically needed 08:10
DarthGandalf ah, I see, thanks 08:49
that's surprising :(
$@foo still should have worked though, as it doesn't use the [] syntax 08:50
09:07 Manifest0 joined 09:15 dakkar joined
lizmat DarthGandalf: yeah, I think *that* is the bug 09:22
DarthGandalf lizmat: perhaps it would be good to have some warning about [@foo]? 10:48
lizmat in what way? 10:50
DarthGandalf like, a linter 10:51
or compiler warning
I tried to use that syntax when trying to make it work, and a warning would advice to add , there
since [@foo] by itself is not very useful, trying to convert an array to an array 10:52
lizmat I think in RakuAST we would be able to add a worry 10:53
OTOH, [@a] is a valid way to create a clone of an array 10:54
nemokosch Yeah this is design... "seemed like a good idea at first" 11:06
Also means that wrapping is idempotent
[[$x]] and [$x] are the same 11:07
17:36 dakkar left 19:22 ab5tract left, ab5tract joined, guifa left 19:24 guifa joined, kjp left 19:25 kjp joined