📘 String concatenation operator ~ in Perl 6

📘 String concatenation operator ~ in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.


~ does the string concatenation. The dot in Perl 6 is now used for dealing with methods; thus, a new operator for the string concatenation was required. The tilde was a good candidate because it is also used in other string-related operators in Perl 6.

say "a" ~ "b"; # ab

If necessary, the operator converts its operands to the string type.

say "N" ~ 1; # N1
say 4 ~ 2;   # 42

Leave a Reply