Search code examples
rakustring-interpolation

String interpolation in Perl6


I have difficulty figuring out why the statement

say "\c500";

produces the character 'Ǵ' on my screen as expected, while the following statements give me an error message at compile time ("Unrecognized \c character"):

my $i = 500;
say "\c$i";

even though

say "$i"; # or 'say $i.Str;' for that matter

produces "500" (with "$i".WHAT indicating type Str).


Solution

  • You'll have to use $i.chr, which is documented here. \c is handled specially within strings, and does not seem to admit anything that is not a literal.