Is it still safe to delete nullptr in c++0x?

5.3.5/7 says: If the value of the operand of the delete-expression is not a null pointer value, the delete-expression will call a deallocation function (3.7.4.2). Otherwise, it is unspecified whether the deallocation function will be called. And 3.7.4.2/3 says: The value of the first argument supplied to a deallocation function may be a null pointer … Read more

Difference between nil, NIL and, null in Objective-C

nil is the literal null value for Objective-C objects, corresponding to the abstract type id or any Objective-C type declared via @interface. For instance: Nil is the literal null value for Objective-C classes, corresponding to the type Class. Since most code doesn’t need variables to reference classes, its use is not common. One example is: … Read more

How to check for an undefined or null variable in JavaScript?

You have to differentiate between cases: Variables can be undefined or undeclared. You’ll get an error if you access an undeclared variable in any context other than typeof. A variable that has been declared but not initialized is undefined. Undefined properties , like someExistingObj.someUndefProperty. An undefined property doesn’t yield an error and simply returns undefined, which, when converted to a boolean, evaluates to false. So, … Read more

set head to NULL (‘NULL’ : undeclared identifier)

As written, NULL isn’t defined in your program. Usually, that’s defined in a standard header file — specifically <cstddef> or <stddef.h>. Since you’re restricted to iostream, if yours doesn’t get NULL implicitly from that header, you can use 0 or, in C++11, nullptr, which is a keyword and doesn’t require a header. (It is not recommended to define NULL yourself. It might work sometimes, but it is technically … Read more

Is there a standard function to check for null, undefined, or blank variables in JavaScript?

You can just check if the variable has a truthy value or not. That means will evaluate to true if value is not: null undefined NaN empty string (“”) 0 false The above list represents all possible falsy values in ECMA-/Javascript. Find it in the specification at the ToBoolean section. Furthermore, if you do not know whether a variable exists (that means, if it was declared) you should check with the typeof operator. For instance … Read more

Is null reference possible?

References are not pointers. 8.3.2/1: A reference shall be initialized to refer to a valid object or function. [Note: in particular, a null reference cannot exist in a well-defined program, because the only way to create such a reference would be to bind it to the “object” obtained by dereferencing a null pointer, which causes … Read more

How to check if object is null or not except == null

The easiest way to check is entity == null. There is no shorter way to do that. Note that there is a method for this in the standard lib: Objects.isNull(Object obj) And another one which is the opposite of the above one: Objects.nonNull(Object obj) And there is yet another one which can be used to force … Read more