When I run this script in Raku I get the letter A with several newlines.
Why do I not get the concatenated strings as expected (and as Perl5 does) ?
EDIT BTW can I compile in commaIDE the file with the Perl5 compiler, where can I change this compiler to be that of Perl5 ?
say "A";
my $string1 = "00aabb";
my $string2 = "02babe";
say join ("A", $string1, $string2);
print "\n";
my @strings = ($string1, $string2);
say join ("A", @strings);
print "\n";
The solution I suggest is to drop the parens:
(The elements in
@stringsin the second call tojoinare flattened, thus acting the same way as the first call tojoin.)The above code displays:
Your code calls
joinwith ONE argument, which is the joiner, and ZERO strings to concatenate. So thejoincall generates null strings. Hence you get blank lines.The two
say join...statements in your code print nothing but a newline because they're like the third and fourthsaylines below:The first and second lines above pass three strings to
join. The third passes a singleListwhich then gets coerced to become a single string (a concatenation of the elements of theListjoined using a single space character), i.e. the same result as the fourth line.The
my @strings = ($string1, $string2);incantation happens to work as you intended, because an assignment to a "plural" variable on the left hand side of the=will iterate the value, or list of values, on the right hand side.But it's a good habit in Raku to err on the side of avoiding redundant code, in this instance only using parens if you really have to use them to express something different from code without them. This is a general principle in Raku that makes code high signal, low noise. For your code, all the parens are redundant.