- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
That's not C++. C++ does not have "null" as a value. It's either NULL (old style) or nullptr. So the code snippet is either C# or Java I guess.
Admin
Depending on the language here, this might be valid.
In some languages, false == 0 == null == "" == []
If you want to coerce any "falsy" value to null for sanity, you might do the above.
But then again, I would do it like this:
$foo = $foo?$foo:null;
And probably leave a comment to say as much.
Admin
My first thought as well.