thowe | how do I take something like "my $block = { put $_ }" and feed it an array to iterate over? | 00:06 | |
feed @array to $myblock? | 00:07 | ||
MasterDuke | m: my &block = { put $_ }; my @array = <a b c>; @array.map(&block) # you mean something like this? | 00:10 | |
camelia | a b c |
||
thowe | so, use "map"? | 00:11 | |
yeah, map works. That had actually occurred to me and somehow I was convinced Isaw a way to do it by using -> and I guess I didn't. | 00:12 | ||
I love how Raku tells me I am wrong because I am trying to do Perl 5 things... | 00:14 | ||
Raku doesn't really seem to care if I use $myblock or &myblock, which makes me wonder which is actually "more" correct. | 00:15 | ||
MasterDuke | when you're kind of telling it what to do it doesn't matter as much. but for example, using the "right" sigil matters more if you're passing it to a multi-sub/method with candidates for a callable or not | 00:17 | |
thowe | hm, yeah, OK | 00:19 | |
guifa | m: my $block = { say "peso" }; my &block = { say "amp" }; $block; block | ||
camelia | WARNINGS for <tmp>: amp Useless use of $block in sink context (line 1) |
||
guifa | m: my $block = { say "peso" }; my &block = { say "amp" }; sink $block; sink block | 00:20 | |
camelia | amp | ||
guifa | when you assign to &var, you can call it just like any other sub. If you assign to a $var, to call, you'll need to explicitly use parenteses, e.g. $block(1,2,3), vs being able to just do block 1, 2, 3 if you've ampersanded it | 00:22 | |
thowe | ah.. lemme play with that. | 00:28 | |
looks like need to use colon... | |||
"@speeds.map: &speedkb;" works, "@speeds.map &speedkb;" no work. | 00:29 | ||
which is prob to be expected... | |||
guifa | yeah, you need the colon because the colon is used to separate a method from its arguments if you go without parentheses | 01:29 | |
02:43
razetime joined
03:02
m_athias left,
m_athias joined
03:17
frost joined
03:18
frost left
03:20
codesections joined
03:21
frost joined
03:59
discord-raku-bot left,
discord-raku-bot joined
04:43
frost left
04:46
frost joined
05:31
frost left
05:33
frost joined
06:40
frost left
07:14
frost joined
08:39
frost left
10:45
guifa left
16:13
razetime left
21:05
TempIRCLogger joined,
lizmat_ joined
21:06
RakuIRCLogger left,
lizmat left,
TempIRCLogger__ left
|