I believe describing nullness checking as a "main" issue is a rather
strong assessment.

I don't think so, obviously. :-)

$var = (isset($arr['key'])) ? $arr['key'] : 'empty';

Nullness checking is half of what that code does, isn't it? Otherwise it
would be (isset($arr['key']) && $arr['key']), right?

Additionally, it might not be as succinct as you prefer, but surely

$var = $arr['key'] ?? : 'empty';

is a significant improvement over the current means and does in fact remove
redundant code.

But it's not equivalent to your code snippet above, is it?

My vote's still with the line of discussion Hannes and I were on, of
separate 'careful array index lookup' and 'default-when-null'
operator(s). Partly because I think that approach can help everyone,
whereas the checked ternary operator really doesn't help me much at all.
Not sure if that's selfish or not. :-)

I'll try to stay a bit quieter for a bit, if I can manage it.... I've
said a lot today.

Returning due respect,

Ben.




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

Reply via email to