[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Do you ~~ ?



Wasn't aware of this except in the "given/when" example shown.  Very nice!

Also, I thought given/when is in Perl 6 only? Did I miss something?  Admittedly I haven't had as much time to mess with hacking Perl lately!

Best Regards,
Travis

On Apr 1, 2010, at 1:52 PM, Theodore Katseres wrote:

2010/4/1 Jay Hannah <jay@jays.net>
Wow. smartmatch.

use 5.10.0;
if ($a ~~ $b) {

http://perldoc.perl.org/perlsyn.html#Smart-matching-in-detail

Anyone use this beast?

I use implicit smart matching with the  when statement the most.

eg.

given ( $a ) {
    when ( $b ) { dosomething(); }
    default { dosomethingelse(); }
}

--
Ted Katseres
     ||=O=||
_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm

--
Travis McArthur