Documentation for routine eof

Documentation for routine eof, assembled from the following types:

class IO::Handle

From IO::Handle

(IO::Handle) method eof

Defined as:

method eof(IO::Handle:D: --> Bool:D)

Returns True if the read operations have exhausted the contents of the handle.

class IO::CatHandle

From IO::CatHandle

(IO::CatHandle) method eof

Defined as:

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

Returns True if the read operations have exhausted the source handle queue, including the contents of the last handle. Note: calling this method may cause one or more .on-switch calls, while the source handle queue is examined, and the source handle queue may get exhausted.

    (my $f1 = 'foo'.IO).spurt: 'foo';
    (my $f2 = 'bar'.IO).spurt: 'bar';
    with IO::CatHandle.new: :on-switch{ print 'SWITCH! ' }$f1$f2 {
                       # OUTPUT: «SWITCH! » 
        .eof.say;      # OUTPUT: «False␤» 
        .readchars(3);
        .eof.say;      # OUTPUT: «SWITCH! False␤» 
 
        .slurp;        # OUTPUT: «SWITCH! » 
        .eof.say;      # OUTPUT: «True␤» 
    }