I was looking at different ways of doing the same thing and at the moment
was looking at the use of "is" and "=", as I have at times found that I will
do something like
if something = 0
and will get an error that says I can't use "=" (or <>) in this case case I
must use "is" ( or not something is). I am trying to find out when this is
the case - when I can use the "=" and when I have to use "is.
For example, I have a small piece of code checking for the existance of a
session cookie:
if session("tom") = nothing then
trace.warn("Tom not there")
trace.warn("Len(session('Tom')) = " & Len(session("Tom")))
if len(session("Tom")) = 0 then
trace.warn("also got a hit on <> 0")
end if
end if
This can also be run as:
if session("tom") is nothing then
trace.warn("Tom not there")
trace.warn("Len(session('Tom')) = " & Len(session("Tom")))
if len(session("Tom")) = 0 then
trace.warn("also got a hit on <> 0")
end if
end if
So 'session("Tom") = nothing' and 'session("Tom") is nothing' as well as
'Len(session("Tom"))' are all equivalent.
Not sure if there is a best way or just whatever strikes you fancy.
I do know that in some cases you can't use the "=" and must use "is". I
just don't know why in some cases you can use both (or all 3 ways) and in
some cases you must us "is".
Can someone help me out on the difference?
Thanks,
Tom