develooper Front page | perl.perl6.language | Postings from February 2003

Re: Shortcut: ?=

Thread Previous | Thread Next
From:
Joseph F. Ryan
Date:
February 2, 2003 19:10
Subject:
Re: Shortcut: ?=
Message ID:
3E3DDDB1.4040300@osu.edu
Miko O'Sullivan wrote:

>SUMMARY
>
>C<$var ?= $x : $y> as a shortcut for C<$var = $var ? $x : $y>.
>
>
>DETAILS
>
>We have ||=, +=, -=, etc.  These shortcuts (I'm sure there's some fancy
>linguistic term for them) save us a few keystrokes and clean up the code.
>
>So, concerning C<? :>, I find myself doing this type of thing a lot:
>
>    $var = $var ? 1 : 0;
>
>How 'bout a shortcut for that, something like this:
>
>    $var ?= 1 : 0;
>
>
>-miko
>

Doesn't the perl6 //= operator already do what you suggest?


Joseph F. Ryan
ryan.311@osu.edu



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