dimanche 18 juin 2017

How to find "if not null" using switch statement

I have the following switch statement. I'm wondering how to make a case of "If not null". I'm pretty sure this is valid, but i'm not finding anything on the interwebz about it.

// Switch on Count
switch($this->_count) {
    case !"":
        return true;
    break;
    default: 
        return false;
    break;
}

So writing case !"": means when $this->_count is not null return true, otherwise return false. Can't i do this with one of those weird looking if statements? The one written with a "?" and a ":"? I haven't used those much. Any help is appreciated. Thanks!

Aucun commentaire:

Enregistrer un commentaire