develooper Front page | perl.perl5.porters | Postings from December 2017

Re: Revisiting smart match

Thread Previous | Thread Next
From:
Rocco Caputo
Date:
December 19, 2017 14:39
Subject:
Re: Revisiting smart match
Message ID:
0BA0371A-D3AE-4EDA-91B0-7C14CFBEC5A0@pobox.com
> On Dec 19, 2017, at 08:50, Eirik Berg Hanssen <Eirik-Berg.Hanssen@allverden.no> wrote:
> 
>   upon ($baz) { do_stuff(); }
>   do_stuff() upon $baz;
> 
>   when ($_->foo eq 'bar') { do_stuff(); }
>   do_stuff() when $_->foo eq 'bar';


I missed something.  On the surface, the "when" form looks like it has the same syntax and semantics as plain old "if".  Why can't "if" be used in that case? (pun semi-intended)

It's an open question for anyone.  This example just happened to be the one that made me go "hmmm".

-- 
Rocco Caputo <rcaputo@pobox.com>


Thread Previous | 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