To check against null
we generally do if (object == null)
. Instead, would it be nicer to have
if (object is null) {
// Do something
}
Or
if (object is not null) {
// Do something
}
It would be more intuitive, i.e. reads more like english.
EDIT : I got lot of answers. Thanks for the people who up voted, although down votes were overwhelming. That's fine, I don't ask questions to increase my points but rather to gain insight into language design, algorithm, etc. They always try to make languages more intuitive and easy to read. How is it perfectly fine in sql
, but really ugly in java? Some people thought I wanted to have for all equality checks, e.g. if (a is 5)
. No, I wanted to see only for null
s. If getting rid 'BEGIN' and END
made java so elegant, then I don't know what to say. Java put extends
in place of :
for sub class. Did that make it more readable, I would think so. Was getting rid of ;
in groovy a good idea? I would say yes. Have fun.