πŸ“˜ 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

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code