So

$f = so "eraseme.txt".IO.f;

Would do the trick?

On Fri, 29 Sep 2017, 6:56 am Norman Gaywood, <ngayw...@une.edu.au> wrote:

> On 29 September 2017 at 15:10, Brandon Allbery <allber...@gmail.com>
> wrote:
>
>>
>> (And, Norman? It produces a Failure, not a hard exception. You can
>> introspect Failures to keep them from getting thrown.)
>>
>
>  Yep, that's what I thought I'd said :-) Obviously not clearly.
>
> Another way of looking at it:
>
> $ perl6 -e 'my $f = "eraseme.txt".IO.f;say $f.WHAT'
> (Failure)
>
> and you can coerce that to a bool without throwing as other examples in
> the thread have shown.
>
> perl6 -e 'my $f = "eraseme.txt".IO.f; say $f.WHAT; say ?$f'
> (Failure)
> False
>
> Or plain old verbose:
>
> if "eraseme.txt".IO.f {
>     say "exists";
> } else {
>     say "does not exist";
> }
>
> It seems to me it only looks buggy when you are trying to do one liners
> and you don't naturally get a boolean context.
>
> --
> Norman Gaywood, Computer Systems Officer
> School of Science and Technology
> University of New England
> Armidale NSW 2351, Australia
>
> ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
> Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062
>
> Please avoid sending me Word or Power Point attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
>

Reply via email to