if foo(x) <> null
...
endif
definitely works. Casts return null if they can't cast to the type requested.
Only thing to note, though, is that if foo is a base class of bar, then that check will also return a positive for any bar objects. If that's confusing, check this example.
...
endif
definitely works. Casts return null if they can't cast to the type requested.
Only thing to note, though, is that if foo is a base class of bar, then that check will also return a positive for any bar objects. If that's confusing, check this example.
Type Foo Field x:Int End Type Type Bar Extends Foo Field y:Int End Type Local mybar:Bar = new Bar() if( foo(mybar) <> null ) print "mybar is a foo." endif