On 17 Nov 2012 at 01:33, Iñigo Medina <imedina@xxxxxxxxxxxx> wrote: > On Fri, 16 Nov 2012, Jim Giner wrote: >> Maybe I'm way out of touch, but when I look at php.net for the syntax of the >> switch statement I see: >> switch($var){ >> case (value): >> (do something) >> case (other value): >> (do something else) >> } >> >> IN your example, you are using a switch syntax that is nothing like that. I >> think that your "case " statements are not actually evaluating the value of >> $count, but are themselves evaluating to a true value that has nothing to do >> with $count. > > That `switch` is evaluating to true each case. It's an alternative of using > if-elseif structure. It may be an alternative, but it breaks the principle of least surprise. If I'm looking through someone's code, and I see a switch, I expect to see it used as Jim described. If the writer needs a different type of logic to make a decision, that is what the cascaded if-elseif-elseif construct is for, when the tests don't fall into a simple set-of-values choice. The job of a programmer is not to be "clever" with a view to impress those who follow, but to achieve the desired outcome while at the same time making life easy for those who follow. -- Cheers -- Tim
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php