Course of Raku / Essentials / Strings / Exercises / Hello, Concatenation!
Solution: Hello, Concatenation!
Code
Here is a possible solution to this problem:
my $name = prompt 'What is your name? ';
say 'Hello, ' ~ $name ~ '!';
🦋 You can find the source code in the file hello-concatenation.raku.
Output
Run the program, and it will enter a mode when it waits for your input. After you type the name and press Enter, the program goes on and prints the greeting:
$ raku exercises/strings/hello-concatenation.raku
What is your name? John
Hello, John!
Comments
Compare the program with the previous variant where we passed three strings to the say
routine:
say 'Hello, ', $name, '!';
This time, the three parts are first concatenated and then passed to say
as a single string.
Next exercise
Course navigation
← Scalar variables / Names of the variables | Numbers →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська