stevied is there any documentation that talks about the arrays as arguments? 00:11
Nemokosch you mean @ containers or really just arrays? 00:13
stevied i don't know. anything that provides a clear explanation for the reason behind the behavior 00:15
Nemokosch 😬 00:17
stevied stackoverflow.com/questions/707794...gs-are-not 00:29
let's see what people chime in with
Nemokosch 😄 00:36
Yeuph I'll be finished going through the course.raku.org Raku course soon. Are there other recommended materials that a person with no significant coding knowledge (beyond the aforementioned Raku course) should/could continue along? 00:44
stevied there's also this: raku.guide @Yeuph#9974 00:48
Yeuph ty ty 00:49
stevied @Nemokosch#9980 I think this has something to do with containers, which I don't quite understand despite reading the docs on it twice now 00:55
ok, it's spelled out here: docs.raku.org/language/containers#...sty_things 01:07
"an array...forces all it's elements to be containers"
"An Array is just like a list, except that it forces all its elements to be containers, which means that you can always assign to elements:" 01:08
and if you want the array to behave like a scalar (non-mutable), you do something like: 01:10
`my @a := (1, 2, 3);`
I think I'm starting to get it 01:20
you can do this: 01:21
```
sub blah ($arg) { $arg; }
my @array = 1, 2, 3;
blah @array;
say @array;
```
the blah function will be called but $arg is immutable and you can't change @array
but even though it's a scalar, it behaves like an array
actually, not quite right. you can still change the elements of the array 01:23
guifa to answer the core quesion: pass as a list: $arg is immutable, but you can still call methods on @array 02:35
errr
just "$arg is immutable, but you can still call methods on @array"
you'd expect sub foo(Str $a) { $a.substr(0,1) } to work, right? returning the first letter of the string 02:39
stevied but I *think* the reason why `sub blah($str)` is immutable is because `$str` is *bound* to the argument that is passed 02:48
in `sub blah(@array)`, @array is also bound to the argument, but the array itself is mutable
i don't know yet. I'm doing more reading on this until I get my head totally unwrapped around it. 02:49
02:51 frost joined
wrapped 02:54
jaguart I know I'm heading for a Doh! moment - how do I call IO.f on $_? my @files = @names.grep( $_.IO.f );gives No such method 'IO' for invocant of type 'Any'. 03:11
doh: my @files = @names.grep({ .IO.f }); - it's a grep-block-argh thingy 03:16
CIAvash jaguart: you can write `.grep(*.IO.f)` 04:24
04:43 frost left 05:04 frost joined 05:41 frost left 06:04 frost joined 07:10 frost left 08:23 frost joined
Nemokosch Or you can write `{.IO.f}` inside the grep 08:31
You need the block
09:09 dakkar joined 09:11 frost left 10:54 frost joined 11:19 frost left 14:54 discord-raku-bot left, discord-raku-bot joined 15:04 frost joined 15:05 discord-raku-bot left 15:08 discord-raku-bot joined 15:12 discord-raku-bot left 15:13 discord-raku-bot joined 15:35 frost left 15:58 MasterDuke left 16:14 MasterDuke joined 17:34 dakkar left
stevied reading: docs.raku.org/type/Scalar. the first example: `say |(1,2,$(3,4)); ` makes no difference with or without the `$` 19:59
I get the same output
Nemokosch m: say |(1,2,$(3,4)); 20:02
say |(1,2,(3,4));
lizmat that's because the stringification hides the differencw
m: say |(1,2,$(3,4));
camelia 12(3 4)
lizmat m: dd |(1,2,$(3,4));
camelia 1
2
$(3, 4)
Nemokosch m: say |(1,2,(3,4)); 20:03
stevied ok, thanks
Nemokosch maybe this isn't a good example then
lizmat if that was taken from the docs, then maybe a doc issue is in place 20:04
Nemokosch yes, it was
21:04 MasterDuke left 21:21 MasterDuke joined