You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
subload-data {
rand>.5orreturn; # simulated load data failure; return Nil
(rand>.3??'error'!!'good data') xx10# our loaded data
}
load-data.first:/good/andthensay"$_ is good"; # OUTPUT: «(good data is good)»
load-data() andthen.return; # return loaded data, if it's defined die"Failed to load data!!";
Returns (sample):
===11/10/2311:55:27===
Use ofNil in string context
in block <unit> at - line 5
Failed to load data!!
in block <unit> at - line 8===11/10/2311:55:32===
good data is good
Failed to load data!!
in block <unit> at - line 8===11/10/2311:55:38===
Use ofNil in string context
in block <unit> at - line 5
Attempt toreturn outside ofanyRoutine
in block <unit> at - line 7
The Attempt to return outside of any Routine error above seems to distract from the main point of the code.
The text was updated successfully, but these errors were encountered:
I'm thinking what to do about it. I don't really like the whole example (and I also don't like the last paragraph).
The banal fix would be to wrap the whole snippet into a function like analyze-and-load... but that wouldn't improve the convoluted nature of the example.
Example code for
andthen
docs occasionally returns error:Attempt to return outside of any Routine
https://docs.raku.org/routine/andthen
Returns (sample):
The
Attempt to return outside of any Routine
error above seems to distract from the main point of the code.The text was updated successfully, but these errors were encountered: