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.
1, 2, 3, 4, 5, Nil
sub
say
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.
Nil
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);
2.1m questions
2.1m answers
60 comments
57.0k users