Course of Raku / Essentials / Variables and data types essentials / Strings / String concatenation

Quiz 2: Concatenating strings and numbers

Raku automatically converts a number if you want to concatenate it to a string. In each of the parts below, select the lines that print the required string.

1

Which of the lines print Alpha2?

1say 'Alpha2';
0say 'Alpha' 2;A space is a syntax error here.
1say 'Alpha', '2';There is no string concatenation, but the result is correct.
1say 'Alpha' ~ '2';
1say 'Alpha' ~ 2;A number is converted to a string and then concatenated.
0say 'Alpha' + 2;A + does not do string concatenation.
0say 'Alpha' . 2;Neither does a ..

2

Which of these lines print 123?

1say 1 ~ 2 ~ 3;String concatenation here, even for numbers.
0say 1 + 2 + 3;A regular arithmetical expression.
1say '1' ~ '2' ~ '3';Single characters are also strings.
0say '1' + '2' + '3';As there is a +, the strings are converted to numbers.
1say 1 ~ 23;
1say 12 ~ 3;
1say 123 ~ '';'' is an empty string, so appending it does not change the result.

Course navigation

Quiz 1: Concatenating strings   |   Quiz 3: Concatenating strings again

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська