April 12, 2010
The Many Faces of Null

“It is sometimes more convenient and less ambiguous to have a NULL object than to use Java’s null value. JSONObject.NULL.equals(null) returns true. JSONObject.NULL.toString() returns “null”.”

from the JSONObject Java documentation.

This doesn’t make much sense to me, though; JSONObject.NULL is an Object, and therefore logically can’t be equal to null, particularly because that equality check lacks transitivity (that is, JsonObject.NULL.equals(null) is true, but null.equals(JsonObject.NULL) is a compiler error or null pointer exception).

Also, it just feels really gross to me.

  1. ysamlan posted this
Blog comments powered by Disqus