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
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