Page 1 of 1

Checking for null in a script

Posted: 30 Jul 2013 12:43
by manuel
What is the right syntax to check for a null value?

Can I just use the following?

Code: Select all

if ( a != null) {
...
}

Re: Checking for null in a script

Posted: 30 Jul 2013 16:53
by Martin
Yes, this code should work:

Code: Select all

a=null;
if (a==null) {
  log("null");
}
else {
  log("not null");
}
or

Code: Select all

a=null;
if (a!=null) {
  log("not null");
}
else {
  log("null");
}