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.




--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to