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

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

Thread Next
Ed Avis
June 29, 2012 03:55
Smartmatch two cents (was... List::Util... when...)
Message ID:
Father Chrysostomos via RT <perlbug-followup <at>> writes:

>Oh, and let’s deprecate smartmatch while we are at it.

I agree, and for the one case where smartmatch is useful in practice:

    if ($x ~~ @values) { ... }

add a new operator 'in' borrowed from Python

    if ($x in @values) { ... }

which does an 'eq' comparison with each item in the list, stopping and returning
true if one matches, false otherwise.

I would gladly remove smartmatch from my code if Perl provided an 'in' keyword
to replace it, which is the only thing I use smartmatch for anyway.

Ed Avis <>

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