On 18 Nov 2012 at 14:44, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx> wrote: >>>>> 2. Using Switch {ALWAYS FIRST CASE!!!} >>>>> >>>>> // $boxes = 1; >>>>> // switch ($count) { >>>>> // case ($count > 14): >>>>> // $boxes = 3; >>>>> // break; >>>>> // case ($count > 7 && $count <= 14): >>>>> // $boxes = 2; >>>>> // break; >>>>> // case ($count <= 7): >>>>> // default : >>>>> // $boxes = 1; >>>>> // break; >>>>> // } > To answer Iñigo's comment - the OP's version is very much like an > If-ElseIF structure, and nothing like a Switch. Just so. Perhaps those who are not grasping the point could re-read their copy of "The Elements of Programming Style" by Kernighan and Plauger where this sort of issue is covered. See, it's all about expectations. When I worked at SLAC, there was a wise guy there who had removed the catalytic converter from his Scirocco and who though it clever to race up 280 from San Jose to SLAC at 100mph, sometimes slipstreaming behind another idiot doing the same. If I look in my rear-view mirror, I expect those I can see to be doing 70mph tops (that's what a lot of people did 30 years ago on 280), not 100, and to make judgements accordingly. Equally, I have certain expectations when I see a switch statement; it trying hard to look like if-elseif-etc is not one of them. -- Cheers -- Tim
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php