Course of Raku / Essentials / Built-in functions for printing

put

By default, the put routine does the same job as print but adds a newline at the end:

  1. Converts its arguments to a string by calling the Str method on them.
  2. Adds a newline character.
  3. Sends it to the STDOUT stream.

A few examples:

42.put;
put 'Alpha', 'Beta';

my @array = 3, 4, 5;
put @array;

my %hash = a => 'b', c => 'd';
%hash.put;

The outputs of the program:

$ raku t.raku
42
AlphaBeta
3 4 5
a	b
c	d

A newline of put

The actual characters that are added after the output are taken from the nl-out method of the output stream. Its default value is \n.

Course navigation

Built-in functions for printing / print   |   Built-in functions for printing / note


💪 Or jump directly to the exercises to this section.