getc
ErrorsCollection

getc

Synthesised documentation from type/independent-routines type/IO/Handle type/IO/CatHandle

From type/independent-routines

See Original text in context

multi sub getc  (IO::Handle:D $fh = $*ARGFILES{ $fh.getc  }

This routine is a wrapper for the method of the same name in IO::Handle>. If no Handle is specified, defaults to $*ARGFILES.

From type/IO/Handle

See Original text in context

method getc(IO::Handle:D: --> Str:D)
multi sub getc (IO::Handle $fh = $*ARGFILES --> Str:D)

Reads a single character from the input stream. Attempting to call this method when the handle is :$enc will result in X::IO::BinaryMode exception being thrown. The subroutine form defaults to $*ARGFILES if no handle is given. Returns Nil, if no more input is available, otherwise operation will block, waiting for at least one character to be available; these caveats apply:

From type/IO/CatHandle

See Original text in context

method getc(IO::CatHandle:D: --> Bool:D)

Returns a single character of input from the handle. All the caveats described in IO::Handle.getc apply. Returns Nil when there is no more input. It is an error to call this method when the handle is :$encoding, resulting in X::IO::BinaryMode exception being thrown.

(my $f1 = 'foo'.IO).spurt: 'I ♥ Raku';
(my $f2 = 'bar'.IO).spurt: 'meow';
my $cat = IO::CatHandle.new: $f1$f2;
.say while $_ = $cat.getc# OUTPUT: «I␤ ␤♥␤ ␤R␤a␤k␤u␤m␤e␤o␤w␤»