Writing Cast Method

BlitzMax Forums/BlitzMax Beginners Area/Writing Cast Method

H&K(Posted 2006) [#1]
You know the way that
Int(10.0:Float)
will return an int.
Can I write a method/function to use the same syntax for my types (That are not inherted).
ie
AType (Bob:BType)
or do I have to
Function CastBtypeToAtype:Atype (Bob:Btype)

Thanks


Dreamora(Posted 2006) [#2]
You can have the same for your types, assumed that BType extends AType

Otherwise direct casting is not possible at all and you would need to write Cast Methods (not functions normally. Methods simimlar to toString() on :Object). Those actually would not cast but create a new object, fill it with the needed values and return it.