develooper Front page | perl.perl5.porters | Postings from July 2012

Re: Smartmatch two cents (was... List::Util... when...)

Thread Previous | Thread Next
Ricardo Signes
July 5, 2012 19:47
Re: Smartmatch two cents (was... List::Util... when...)
Message ID:
* Ed Avis <> [2012-07-03T04:59:34]
> As in Python, 'in' could work for both arrays and hashes:
>    $x in @array
>    $x in %hash    # same as exists $hash{$x}

Alas, Perl is not Python, and alas, Python is not Perl.  The "in" operator in
Python works nicely because Python's type system is different to Perl's.

We're not going to be adding an `in` operator, because it goes against the
idea of where Perl decides what type to use.  Fortunately, Perl6::Junction and
other libraries provide excellent tools for doing this kind of scanning.  I use
them all the time and don't regret it for a second.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About