On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users wrote:
> In 2020-05-18 16:11, Peter Pentchev wrote:
> > As an exercise for the reader: once the above sinks in, what exactly
> > will "say if 'h:/'.IO.d" do?
> 
> It returns the the result of the expression that
> "if" evaluated.

OK, so why does it give you an error message if you run it? :)

Not quite.

    say if 'h:/'.IO.d

...is equivalent to:

    if 'h:/'.IO.d {
        say;
    }

....which would have been valid in Perl (apart from the parentheses
around the condition of the "if", Raku allows you to omit those), but
it is not valid Raku. Run it and see what it says.

Once again you thought that "if" returns a value. "If" does not return
a value, it is not a function, it is a statement. Just the same as "for"
does not return a value, and "while" does not return a value.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature

Reply via email to