RE: [PHP] Short writage of clauses

From: Date: Mon, 12 Jun 2006 05:16:22 +0000
Subject: RE: [PHP] Short writage of clauses
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237795@lists.php.net to get a copy of this message
Switch($a) { Case 1: Dowhatyouwant(); Case 2: Dowhatyouwant(); Default: Dowhatyouwant(); } -----Original Message----- From: Barry [mailto:barry@flyerheaven.de] Sent: Monday, June 12, 2006 5:12 PM To: php-general@lists.php.net Subject: Re: [PHP] Short writage of clauses 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

« previous php.general (#237795) next »