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.
habere-et-disper So assuming I have an array and it might be empty, then does this seem reasonable : 00:04
m: say <foo bar>.Hash{ [].pop // False }
camelia (Any)
nemokosch not an easy reading - why are you indexing the Hash with literally False? 00:05
habere-et-disper I don't want to. I just want to handle the case when the array might be empty: 00:09
m: say <foo bar>.Hash{ [].pop } 00:10
camelia Cannot pop from an empty Array
in block <unit> at <tmp> line 1
nemokosch that's the best I can think of 00:12
habere-et-disper Thanks ! 00:14
01:43 habere-et-disper left 05:26 siavash joined 06:53 ab5tract joined 08:13 dakkar joined 08:20 tea3po joined 08:23 teatwo left 08:58 guessed joined 09:10 guessed left 12:14 ab5tract left 12:57 siavash left 13:34 jgaz joined 14:06 ab5tract joined 14:10 ab5tract left 14:11 ab5tract joined 14:35 ab5tract left
jgaz Is is possible to define a signature that expects to return one of TWO possible types? Example: An Int (usually) or a NaN (given some failure)? 15:10
nemokosch via runtime checks yes but not as a dedicated metamodel feature 15:19
jgaz ok 15:38
lizmat m: subset A where * ~~ Int | NaN; sub a($a --> A) { $a }; a 42; a NaN; a pi 15:39
camelia Type check failed for return value; expected A but got Num (3.141592653589793e0)
in sub a at <tmp> line 1
in block <unit> at <tmp> line 1
lizmat you can hide the runtime check on a subset though
15:53 hythm joined 16:43 dakkar left 18:57 ab5tract joined 19:27 ab5tract left 19:32 thowe left 19:52 thowe joined 20:20 teatwo joined 20:23 tea3po left 21:47 tea3po joined 21:49 teatime joined 21:51 teatwo left 21:52 tea3po left 22:34 deoac joined