[Gambas-user] subtyping (coercing) heirarchical objects

Benoît Minisini gambas at ...1...
Tue Oct 16 12:52:36 CEST 2012


Le 16/10/2012 12:44, Bruce a écrit :
> Given a collection "c" of objects of type "x" and an inheritance
> hierarchy where "x1" and "x2" are subtypes of "x", is there an easy way
> to cast c[id] to the proper subtype ( i.e ":x1" or ":x2") when some
> occurrence allows a logical discernment between the subtypes?
>
> Bruce
>

x1(c[id]), provided that x1 does not implement the "_call" special method.

Or assigning to another variable of type "x1" if find the previous 
syntax confusing.

Regards,

-- 
Benoît Minisini




More information about the User mailing list