On 2019-12-07 18:30, Mark Senn wrote:
Corrected section

        my %h = a => "x", b=>"r", c=>"z";
        if %h<d> { say "exists"; } else { say "DOES NOT exist"; }
        DOES NOT exist

        if %h<b> { say "exists"; } else { say "DOES NOT exist"; }
        exists

Hi.

The following code prints DOES NOT exist twice.

my %h = a => "x", b=>0, c=>"z";
if %h<d> { say "exists"; } else { say "DOES NOT exist"; }

if %h<b> { say "exists"; } else { say "DOES NOT exist"; }


I changed the b=>"r" to b=>0.  I think it is evaluating
the b element as a boolean---I think the exists adverb
needs to be used to check for existence.

-m


Hi Mark,

Oh bugger!


This is what I get:

$ perl6
To exit type 'exit' or '^D'
> my %h = a => "x", b=>"r", c=>"z";
{a => x, b => r, c => z}

> if %h<d> { say "exists"; } else { say "DOES NOT exist"; }
DOES NOT exist

> if %h<b> { say "exists"; } else { say "DOES NOT exist"; }
exists


Would someone else please run my code and see if
they can reproduce Mark's error?

Many thanks,
-T

Reply via email to