Re: Short writage of clauses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jochem Maas schrieb:
 > I find a switch statement sometimes handy for creating a 'truth table'
like you describe (I sometimes find it easier to read and/or add 'if' clauses):

switch (true) {
	case ($grandmaAge >= $tableAge):
	case ($grandmaAge < $houseAge):
	case ($grandmaAge == array_sum($grandKids)):
		bakeCookie();
		break;
	default:
		haveABeer();
		watchFootball();
}

functionally the above could just as well be an if statement - it's pretty much
a question of personal preference.

Yeah true, it is better to view.
Is it the same as the if i stated? (the grandma one)
it's one if but not multiple ones (if elseif elseif .. etc.)

The problem still is it's not that "short" ;)

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux