my sub e($r) { printf("%d, ", $_) for 1..$r}
say e(5);
returns 1, 2, 3, 4, 5, Nil
that is, the sub
and/or say
consistently adds a Nil to the end.
I first tried it using rakudo version 2020.02. I've tried now using the latest version 2020.12.1 and that Nil is still there. How to get rid of it?
Nil
is the return value of the sub e
.
You either want
my sub e($r) { printf("%d, ", $_) for 1..$r}
e(5);
or
my sub e($r) { map { sprintf("%d, ", $_) }, 1..$r }
.say for e(5);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With