Subscribe to PHP Freaks RSS

PHP 8.0 feature focus: <span>nullsafe methods</span>

syndicated from on October 7, 2020

Last week we used Weak Maps to solve one edge case. Today, we simplify the most common and annoying edge case: That of nothingness. Let’s be honest, null values suck. They’ve been called the billion dollar mistake, but programmers in most languages still have to deal with it. (Except for those working in Rust.) They especially suck when you have a variable that could be an object or null. If it’s an object, presumably you know it’s type and what it can do; if it’s null, you can’t do much of anything with it.