Hi,

Something like:

function match($x) {
    switch(true) {
        case $x === 1:
            return 'Tiny';
        case is_numeric($x) && $x <= 10:
            return 'Small';
        case is_numeric($x) && $x <= 20:
            return 'Medium';
        case is_numeric($x) && $x <= 30:
            return 'Large';
        case is_numeric($x) && ($x >= 31 || $x <= 100):
            return 'Enormous';
        case $x instanceof Foo:
        case $x instanceof Bar:
            return 'What?';
        default:
            return 'Unknown';
    }
}

the problem is you need is_numeric because no type safe version of <= and >= exists.


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

Reply via email to