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.
06:34 lizmat joined 08:04 librasteve_ joined 13:47 msiism joined
msiism Is there a shorter way to get the index number of the last character in a string than `chars($word) - 1`? 13:49
disbot3 <nahita3882> if strings were iterable, .end would be it but it gives the wrong answer 14:14
<nahita3882> so, no most probably
<nahita3882> method form with .chars saves 1 character :y
<nahita3882> a longer, bad way is $word.match(/$/).pos.pred 14:16
<nahita3882> lastly, one might need to be careful for empty strings
msiism Looking at it again, the `chars($word) - 1` is actually pretty concise. 14:30
What I would really like to have is a way to obtain a letter from a certain index, without having to use substr. 14:31
Something like `getchar($string, $index)`. 14:32
I mean character, of course, not letter. Just currently woking only with letters here… 14:59
disbot3 <librasteve> msiiam: once you embrace unicode as graphemes, then the idea of a character independent of the bytes before and after it no longer holds 15:01
<librasteve> dev.to/bbkr/unicode-vs-utf-4g8c <=== this set of posts is a bit of an eye opener 15:03
16:09 msiism left 16:42 human-blip left 16:44 human-blip joined
disbot3 <jubilatious1_98524> m: my $word = 'cat'; $word.index('c').put; 21:22
<Raku eval> 0
<jubilatious1_98524> m: my $word = 'cat'; $word.index('a').put;
<Raku eval> 1
<jubilatious1_98524> m: my $word = 'cat'; $word.index('t').put;
<Raku eval> 2 21:23
<jubilatious1_98524> @msiiam ☝️ 21:24
21:35 msiism joined
msiism To break an unconditional loop, do I simply use return? 21:37
Uhh… no, I don't, because return is for returning from routines. 21:39
Seem like there's no break statement in Raku.
disbot3 <antononcube> See last; 21:40
<antononcube> docs.raku.org/syntax/last 21:41
msiism Okay, thanks. 21:43
22:06 msiism left
disbot3 <jubilatious1_98524> @nahita m: my $word = 'cat'; put $word.elems - 1; 22:32
<jubilatious1_98524> m: my $word = 'cat'; put $word.elems - 1; 22:33
<Raku eval> 0
<jubilatious1_98524> m: my $word = 'cat'; put $word.comb.elems - 1; 22:34
<Raku eval> 2
<jubilatious1_98524> m: my $word = "cat"; .put with $word.index("z"); 23:38
<Raku eval>