4 ms·
Depends on the language, C# won't allow that, if's don't accept null, they accept bool.
by gnaritas 10y ago
Depends on the language, C# won't allow that, if's don't accept null, they accept bool.
- maccard 10y agoTrue. I was speaking of C++, which also accepts bool [0] (or more specifically, something that can be converted to a bool, which a null pointer can be [1]). Actually [0] has a good example of when the if (Foo* a = ...) syntax is useful (dynamic cast) [0] http://en.cppreference.com/w/cpp/language/if http://en.cppreference.com/w/cpp/language/if [1] https://ideone.com/im4uVn https://ideone.com/im4uVn