Documentation for routine say

Documentation for routine say, assembled from the following types:

class Mu

From Mu

(Mu) method say

multi method say(--> Bool:D)

Prints value to $*OUT after stringification using .gist method with newline at end. To produce machine readable output use .put.

say 42;                 # OUTPUT: «42␤» 

role IO

From IO

(IO) sub say

Print the given text in human readable form, followed by a $*OUT.nl-out (platform dependent newline) on $*OUT (standard output). Long output may be truncated. For machine readable output use put.

With say, the example code as mentioned in the print section will be displayed as the user likely intended:

say "Hi there!";
say "How are you?";
say (0..101).list;

displays

Hi there!
How are you?
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...)␤

say prints non-Str objects by calling their .gist method before printing. Hence the following say statements for the respective containers are equivalent:

my @array = qw{1 2 3 4};
say @array;       # OUTPUT: «[1 2 3 4]␤» 
say @array.gist;  # OUTPUT: «[1 2 3 4]␤» 
 
my %hash = "a" => 1"b" => 2"c" => 3;
say %hash;        # OUTPUT: «{a => 1, b => 2, c => 3}␤» 
say %hash.gist;   # OUTPUT: «{a => 1, b => 2, c => 3}␤» 

class IO::Handle

From IO::Handle

(IO::Handle) method say

method say(IO::Handle:D: |)

This method is identical to print except that it stringifies its arguments by calling .gist on them and auto-appends a newline, with a call to print-nl, after the final argument.

my $fh = open 'path/to/file':w;
$fh.say(Complex.new(34));        # RESULT: «3+4i\n» 
$fh.close;

class Proc::Async

From Proc::Async

(Proc::Async) method say

method say(Proc::Async:D: $output:$scheduler = $*SCHEDULER)

Calls method gist on the $output, adds a newline, encodes it as UTF-8, and sends it to the standard input stream of the external program, encoding it as UTF-8.

Returns a Promise that will be kept once the data has fully landed in the input buffer of the external program.

The Proc::Async object must be created for writing (with Proc::Async.new(:w, $path, @args)). Otherwise an X::Proc::Async::OpenForWriting exception will the thrown.

start must have been called before calling method say, otherwise an X::Proc::Async::MustBeStarted exception is thrown.