Hey, say I have two instances of a class, A and B: how do I make the first instance "equal" to the second in all fields?
A=B passes a pointer and screws
A=B passes a pointer and screws
Type TMyType Field A% Field B% Method Assign(P_source: TMyType) A% = P_source.A% B% = P_source.B% End Method End Type local aType: TMyType local bType: TMyType aType = New TMyType bType = New TMyType aType.A% = 100 aType.B% = 200 bType.Assign(aType) ' ' bType now has all the same values as aType but is a ' different Instance. '
Type TVector Field xcomponent:Double, ycomponent:Double Method deepClone:TVector() Local myVector:TVector = New TVector myVector.xcomponent = xcomponent myVector.ycomponent = ycomponent Return myVector End Method End Typethen you just invoke it as if you where creating a new object:
myVectorAClone = myVectorA.deepClone()Idealy such behaviour should be determined by an Interface, but BlitzMax sadly doesn't have those.