Re: Re: Clarification on the Enum language structure

From: Date: Sat, 19 Feb 2011 05:28:55 +0000
Subject: Re: Re: Clarification on the Enum language structure
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-51473@lists.php.net to get a copy of this message
class Grade { enum { A_PLUS, A, B_PLUS, B, ..., FAIL, NOT_AVAILABLE, } public static function passing($grade) { return $grade>=self::D; } } $grade=Grade::B; echo Grade::passing($grade)?"passing":"not passing";
Shouldn't that be: public static function passing($grade) { -return $grade>=self::D; +return $grade<=self::D; The passing grades all appear before D in the enum, and I expect those to have lower values. Also, I would probably put NOT_AVAILABLE first, since it's underlying value is 0. But then the programmer isn't supposed to consider the underlying values...
I agree with all you said. Ben.

« previous php.internals (#51473) next »