-Original Message-
From: Jason [mailto:networkad...@emarket2.com]
Sent: 21 October 2010 11:45
What about something simple and readable like:
($string==true) ? true : false;
... and wasteful. The above gives exactly the same result as
($string==true)
Cheers!
Mike
--
Mike
-Original Message-
From: Gary [mailto:php-gene...@garydjones.name]
Sent: 21 October 2010 11:39
To: php-general@lists.php.net
Subject: [PHP] Re: My truth comes out [1]
Russell Dias wrote:
preg_match(/false/i, $string) ? false : true;
,
| $foo = (strcmp('true', $string) == 0
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:
[snip]
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;
`
On 10-10-21 06:39 AM, Gary 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
[snip]
You removed the text in my post that you replied to which said I was
just wondering whether I had missed some construct in the language.
[/snip]
Yes, I read that and snipped it. I was just referring to the
readability statement.
--
PHP General Mailing List (http://www.php.net/)
To
On 10-10-21 09:24 AM, Gary wrote:
Jay Blanchard wrote:
You could even create a function that is more readable than the 'if'
alone;
Of course I can. I could also record an explanation, convert it to mp3,
host it on a website, and include the URL in a comment.
You removed the text in my post
7 matches
Mail list logo