Re: Re: Switch - Case Statement Questions

From: Date: Sat, 17 Nov 2012 18:32:04 +0000
Subject: Re: Re: Switch - Case Statement Questions
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-319724@lists.php.net to get a copy of this message
On Nov 16, 2012 10:24 PM, "tamouse mailing lists" <tamouse.lists@gmail.com> wrote: > > On Fri, Nov 16, 2012 at 12:41 PM, Sebastian Krebs <krebs.seb@gmail.com> wrote: > > Beside this it can be rewritten as > > > > switch ((int) (($count-1) / 7) { > > case 0: // 1-7 > > case 1: // 8 - 14 > > default: // above 15 > > } > > Nice code refactoring :) Just a tad obscure for someone coming along > later Not only obscure, but depending on the rule being processed could be plain wrong. It works for the values shown so far, but what if another test is added to the use case in the future that doesn't fit the clever solution? Without knowing the intent of the code, it could be a headache to maintain. Just my 2 cents. Andrew

« previous php.general (#319724) next »