Course of Raku / Essentials / Functions essentials / Built-in functions for printing
print
The print built-in routine does the following:
- Converts its arguments to a string by calling the
Strmethod on them. - Sends it to the
STDOUTstream.
For simple data types, the output generated by print is
similar to the output of say without
the newline character at the end.
print 42;
print 'Raku';These values are printed one after another. There is no newline at the end of the whole output, too.
$ raku t.raku
42RakuFor aggregate data, the result may differ from what you see with
say. For example, try arrays and hashes:
my @data = 'alpha', 'beta', 'gamma';
print @data;
print "\n"; # To separate the parts
my %data = alpha => 1, beta => 2, gamma => 3;
print %data;This is what the output looks like:
$ raku t.raku
alpha beta gamma
alpha 1
beta 2
gamma 3The print routine can also be called as a method:
my @data = 'alpha', 'beta', 'gamma';
@data.print;
"\n".print;Course navigation
💪 Or jump directly to the
exercises in this section.
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська