I would stay clear of the ternary operator in nested coditions, for
obvious reasons. If it can fit in a single line and is essentially
clear in its message I dont see why not to use it.

On Thu, Oct 21, 2010 at 8:39 PM, Gary <php-gene...@garydjones.name> wrote:
> Russell Dias wrote:
>
>> preg_match("/false/i", $string) ? false : true;
>
> ,----
> | $foo = (strcmp('true', $string) == 0);
> `----
> works as well :) I don't like those kinds of things for this purpose
> because it takes longer for people new to the code to read and
> understand it than, say
> ,----
> | (boolean) $string;
> `----
> (which in my case does a pretty meaningless conversion)
>
> No, I was just wondering whether I had missed some construct in the
> language that might the conversion for me, and be obvious to
> PHP-heads. No problem that there doesn't seem to be.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to