routine put

Documentation for routine put, assembled from the following types:

class Mu

From Mu

(Mu) method put

multi method put(--> Bool:D)

Prints value to $*OUT, adding a newline at end, and if necessary, stringifying non-Str object using the .Str method.

"abc".put;              # RESULT: «abc␤» 

role IO

From IO

(IO) sub put

Defined as:

multi sub put(**@args --> True)

Same as print, except appends $*OUT.nl-out (a newline, by default) at the end:

put "Hi there!\n";   # OUTPUT: «Hi there!␤␤» 
put "Hi there!";     # OUTPUT: «Hi there!␤» 
put [123];       # OUTPUT: «1 2 3␤» 

class IO::Handle

From IO::Handle

(IO::Handle) method put

Defined as:

multi method put(**@text --> True)

Writes the given @text to the handle, coercing any non-Str objects to Str by calling .Str method on them, and appending the value of .nl-out at the end.

Attempting to call this method when the handle is in binary mode will result in X::IO::BinaryMode exception being thrown.

my $fh = 'path/to/file'.IO.open: :w;
$fh.print: 'some text';
$fh.close;

class IO::CatHandle

From IO::CatHandle

(IO::CatHandle) method put

Defined as:

multi method put(|)

In Rakudo, the IO::CatHandle type overrides this method to throw X::NYI exception. If you have a good idea for how this method should behave, tell Rakudo developers about it!

role IO::Socket

From IO::Socket

(IO::Socket) method put

method put(IO::Socket:D: Str(Cool$string)

Writes the supplied string, with a \n appended to it, to the socket, thus sending it to other end of the connection.

Fails if the socket is not connected.