Is

From REALbasicWiki

Jump to: navigation, search

Given two object references, the Is operator returns a Boolean value: true if the two references refer to the same object, false if they do not.


For example, the code snippet

dim c1 as new Class1
dim c2 as new Class1
return c1 Is c2

returns false.

But this one returns true.

dim c1 as new Class1
dim c2 as Class1 = c1
return c1 Is c2


Beware that the Not operator has higher precedence than Is. As a consequence, the following code will not compile.

dim c1 as new Class1
dim c2 as new Class1
return not c1 is c2

You must use parentheses to make the application of operators clear.

dim c1 as new Class1
dim c2 as new Class1
return not (c1 is c2)
Personal tools
related