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. |
|||
Tirifto | I’ll go with (Str => (Block, Block)). x) Thank you for your help, @nemokosch and kjp! | 00:44 | |
02:24
tea3po joined
02:27
tea3po left,
tea3po joined
02:28
teatwo left
04:45
tg57 joined
04:56
tg57 left
|
|||
nemokosch | Oh kjp is right, I didn't even pay attention to that aspect | 07:00 | |
07:25
ab5tract joined
07:51
ab5tract left
07:55
dakkar joined
09:36
habere-et-disper joined
|
|||
lizmat | and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2023/06/26/2023-...damn-cool/ | 11:26 | |
13:05
jgaz left
13:06
jgaz joined
14:26
teatwo joined
14:29
tea3po left
15:56
ab5tract joined
16:11
habere-et-disper left
16:35
dakkar left
16:39
ab5tract left
22:53
CIAvash left
22:55
discord-raku-bot left,
discord-raku-bot joined
|
|||
drudgesentinel | I was trying to split a raku regex up earlier- is this a sane approach? my $date-regex = rx/ $<year> = /d ** 4 '-' $<month> = /d ** 2 '-' $<day> = /d ** 2 / | 23:37 | |
I gave up on using this approach, but was hoping to use named captures to print lines in more readable format | 23:38 | ||
an example string: 2023-06-22T19:12:16+00:00 | |||
so if i wanted to grab the year, month, day out of this via a regex capture (and in my particular case this date format can be assumed) | 23:39 | ||
the thing would compile, but I couldn't figure out how to pull out the individual matches from a .match | |||
roguerakudev | Shouldn't those /d's be \d's? | 23:41 | |
nemokosch | Do you have a JS background? In JS, you can indeed look up keys of a hash as if it was an attribute of an object but you cannot do that in most languages | 23:46 | |
drudgesentinel | Yes, sorry. Was hastily typing pseudocode | ||
Yes also, though I'm not a 'real' programmer most of my experience is in node | 23:47 | ||
roguerakudev | Oh, I see what you mean now | ||
nemokosch | For the better or worse, I think this really sticks from JS, this mentality that hashes and records/objects are the same thing from different angles | 23:48 | |
In Raku, you can do a hash lookup using {} or <> so quite nicely <year> called on the match object would work presumably | 23:49 | ||
roguerakudev | Yes, that's what I was trying to find | 23:50 | |
nemokosch | I'd double check the syntax and precedence of named captures just to be sure | ||
roguerakudev | you can treat the resulting match like a hash | ||
so $<submatch> is going to default to looking at $/ (most recent match), but if you didn't match in a way that sets $/, you need to look up on whatever you assigned into with something like $match-obj<submatch> | 23:51 |