πŸ“˜ String concatenation operator ~ in Perl 6

~ 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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s