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

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

Thread Next
From:
Ed Avis
Date:
June 29, 2012 03:55
Subject:
Smartmatch two cents (was... List::Util... when...)
Message ID:
loom.20120629T125101-516@post.gmane.org
Father Chrysostomos via RT <perlbug-followup <at> perl.org> 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 <eda@waniasset.com>


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About