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.
02:16 razetime joined 03:47 razetime left 04:36 razetime joined 04:42 razetime left 06:12 siavash joined 08:47 ab5tract joined 11:59 siavash left 13:29 ab5tract left 14:55 razetime joined 15:20 jgaz left 16:13 ab5tract joined 16:33 ab5tract left 16:46 jgaz joined
su.shi hello ,I'm trying to use the File::Find module and in their example they have .say for find dir => '.'; I'm not sure what the => syntax is doing, and when i look at the docs for for and throughout the operator docs, ican't find info about it 17:58
antononcube @sushi Maybe, I can clarify by re-writing, 18:00
for find(dir => '.') -> $f { say $f } 18:01
su.shi ohh, is it a named parameter?
thank you 18:02
now im wondering, is there a way for me to gather all of the files into an array by doing something like my @files = for find dir => '.'; on one line ? 18:03
antononcube Doesn't that work default like that? 18:06
Meaning does this work: my @files = find(dir => '.'); 18:07
su.shi ah it does lol 18:08
getting too excited with syntax
my @files = gather { take $_ for find dir => '.' }; i found this
obviously redundent though since i am just consuming the elements of a list into another 18:09
antononcube Well, if you have a "deep" directory (with sub-directories) you might prefer to flatten the hierarchy in to an array of strings/files. 18:10
(I am not sure "Find::File" is doing -- haven't used it...) 18:11
su.shi just recursively walks a directory and returns a list of its files 18:12
oh it returns a lazy list, so i suppose if i wanted to get all of the elements as soon as i call this would be a way to do it 18:14
antononcube ok. 🙂
su.shi thanks for the help! 18:15
antononcube @su.shi Good luck! 18:21
18:24 razetime left
su.shi how do i check if a file handle is a directory? 18:55
oh i see 19:00
what's a good way to get line number in raku? in perl i would just use $., but that's gone, so can i use something like enumerate from python on the lines Seq? 20:57
or yeah, im using kv on lines, but mi not sure how to consume the line number from it 20:59
antononcube @sushi I am not sure I understand correctly... Does this work: for "sashimi".comb.kv -> $k, $v { say "$k : $v "} 21:01
su.shi does the same syntax work for while? im using while like i did in perl rn: while my $line = $fh.lines and i tried consuming the line num by doing while my ($num, $line) = $fh.lines.kv but it complains about an uninitialized var 21:03
ah i got it, should have been using for not while 21:21
nemokosch What Anton wrote is clear and concise 21:47
22:48 habere-et-disper joined
habere-et-disper Are these two statements strictly equivalent ? Any caveats ? 22:55
if $condition { thing-1; thing-2; }
$condition && { thing-1; thing-2; }
nemokosch Well, return value? 23:38
habere-et-disper Is the return value not the same for both cases? (Either False if $condition fails, or thing-2 if True.) 23:42
nemokosch Probably not but I don't know but heart 23:44
If $condition were a falsy non-boolean value, && would surely return it as-is, though 23:45
habere-et-disper Thanks. 23:57