AddList / removeList

BlitzMax Forums/BlitzMax Beginners Area/AddList / removeList

Hi. I have an object of type TBall (called PlayerBall) and a list of TBalls (called ballList). What I'd like to do is swap playerBall with the first in the list of ballList. (so playerBall becomes first in the list of BallList and the first object in BallList now becomes PlayerBall).

To copy the first in the list of BallList I have done this:

'Make a copy of playerBall:
Local tempPlayerBall:TBall
tempPlayerBall= playerBall

'Then remove the first item on the list and assign it to player ball
playerBall=TBall(ballList.removefirst())

'And finally add tempPlayerBall (a copy of original playerBall) to the list:
ballList.AddFirst(tempPlayerBall)


I'm getting some strange results and I'm assuming its down to what I'm doing here?
thanks