Testing for Null and not Null in Mathematica

Viewed 7706

What is the best / cleanest / advisable way to test if a value is Null in Mathematica ? And Not Null?

For example:

 a = Null
 b = 0;
 f[n_] := If[n == Null, 1, 2]
 f[a]
 f[b]

has the result:

 1
 If[0 == Null, 1, 2]

Where I would have expected that 2 for f[b].

2 Answers
Related