The docs state that "The simplest way to run a block where it cannot be a stand-alone statement is by writing do
before it" and provide the following example:
# This dies half of the time
do { say "Heads I win, tails I die."; Bool.pick } or die; say "I win.";
However, do
doesn't seem to cause all blocks to run. In particular, it doesn't seem to run blocks with a signature:
do -> $a = 42 { say "ran with $a"; 0 } or die; say 'done'; # OUTPUT: «done»
So would it be better to say that do
treats a block as an expression which sometimes causes it to be run? Or is Rakudo incorrect in its behavior here? Or is my understanding incorrect?