Perl ||= operator for PHP and Javascript

Posted by zaf on Stack Overflow See other posts from Stack Overflow or by zaf
Published on 2010-05-03T09:42:23Z Indexed on 2010/05/03 9:48 UTC
Read the original article Hit count: 313

Filed under:
|
|
|

Just been re-introduced to the Perl '||=' operator from the classic Orcish Maneuver example:

keys my %or_cache = @in;
@out = sort {
    ($or_cache{$a} ||= KEY($a))
    cmp
    ($or_cache{$b} ||= KEY($b))
} @in;

Is this operator available in PHP and Javascript?

And if not, do these two languages allow user defined operators?

© Stack Overflow or respective owner

Related posts about perl

Related posts about php