Type casting ?
Posted: Sun Apr 29, 2012 10:28 am
Hi, is there a casting operator in cobra ?
At the moment, i think i have to do this to pass two ChildClass object to the doSomethingSpecial method
when this would be what i do in other languages
and this would be the ideal syntax
Is there a better way of doing it ?
Berseker59
At the moment, i think i have to do this to pass two ChildClass object to the doSomethingSpecial method
def foo(a as ParentClass, b as ParentClass)
if a inherits ChildClass
if b inherits ChildClass
.doSomethingSpecial(a, b)
when this would be what i do in other languages
def foo(a as ParentClass, b as ParentClass)
if a inherits ChildClass and b inherits ChildClass
a = cast a as ChildClass
b = cast b as ChildClass
.doSomethingSpecial(a, b)
and this would be the ideal syntax
def foo(a as ParentClass, b as ParentClass)
if a inherits ChildClass and b inherits ChildClass
.doSomethingSpecial(a, b)
Is there a better way of doing it ?
Berseker59