Req #32059 [Com]: ranges in switch

From: Date: Mon, 15 Nov 2010 13:44:53 +0000
Subject: Req #32059 [Com]: ranges in switch
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-156048@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=32059&edit=1

 ID:                 32059
 Comment by:         scratch65535 at att dot net
 Reported by:        scooley at apple dot com
 Summary:            ranges in switch
 Status:             Open
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   mac os x
 PHP Version:        5.0.3
 Block user comment: N

 New Comment:

I too think it would be very convenient to allow a range as a case,
e.g.

switch( $somevar )
{
    case 1..5 :
        // code & break
    case 6..23 : 
        // code & break
    // etc
}

(I also think it'd be very convenient if bugzilla didn't claim
"incorrect captcha" when the problem is "i can't set a cookie")


Previous Comments:
------------------------------------------------------------------------
[2005-02-21 23:55:17] scooley at apple dot com

Description:
------------
why not some behavior like this?

...
switch($var)
	{
	case <= 9:
		{
		echo "less than ten";
		break;
		}
	case 10:
		{
		echo "ten exactly";
		break;
		}
	case >10 <> <15:
		{
		echo “a range of values? why not?";
		break;
		}
	case >= 15:
		{
		echo “greater than or equal to fifteen";
		break;
		}
	default:
		{
		echo “what am I not thinking of here?”
		break;
		}
	}
…



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=32059&edit=1


Thread (1 message)

  • scratch65535 at att dot net
  • Unknown Message
    • scratch65535 at att dot net
« previous php.bugs (#156048) next »