Re: ||=

From: Date: Fri, 08 Mar 2002 18:33:14 +0000
Subject: Re: ||=
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-80940@lists.php.net to get a copy of this message
Andi Gutmans <andi@zend.com> wrote: > For some reason this doesn't exist in other languages like C++ and Java. > I don't object to adding this as long as their is no good reason why those > languages didn't support these. > What do other people think? i think, given that php's || and && operators always return a boolean value, people are going to be confused and disappointed with ||= and &&= when coming from languages (like perl) that implement them as returning false or the value that was true. that is, the perl idiom: $value ||= $some_default_value; wouldn't behave as someone familiar with the perl behavior would expect, just like: $value = $user_value || $some_default_value; doesn't. (that said, i've always been +1 on making the behavior of || and && be like perl does it. it is far more useful than merely returning the boolean value of the expression.) jim

« previous php.dev (#80940) next »