Re: Short writage of clauses

From: Date: Mon, 12 Jun 2006 10:11:54 +0000
Subject: Re: Short writage of clauses
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-237792@lists.php.net to get a copy of this message
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)

« previous php.general (#237792) next »