in reply to Re: Perl6 syntax being too much complex? How we will teach and read that?!
in thread Perl6 syntax being too much complex? How we will teach and read that?!

if $foo eq 'bar' or $foo eq 'baz' or $foo eq 'quux' { ... }

Or, the non-hardcoded version ...

my %isAcceptable = map { $_ => 1 } qw( bar baz quux ); if $isAcceptable{$foo} { ... }

------
We are the carpenters and bricklayers of the Information Age.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Re: Perl6 syntax being too much complex? How we will teach and read that?!
by Juerd (Abbot) on Mar 22, 2004 at 17:27 UTC

    Or, the non-hardcoded version ...

    Which sometimes is handy, sometimes not. In any case, this kind of ugly lookup hashes is no longer needed in Perl 6, as any(*@array) will DWYM.

    $isAcceptable{$foo}

    You mean %isAcceptable{$foo}. $foo{$bar} is $foo.{$bar} ($foo->{bar} in Perl 5).

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      NB: probably your * is redundant, since any() will expect a list.

        NB: probably your * is redundant, since any() will expect a list.

        I had any(@foo, @bar).length == 3 in mind. Does that need explicit references too @foo and @bar then?

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }