Get and Set in the same method?

BlitzMax Forums/BlitzMax Beginners Area/Get and Set in the same method?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Type Ship
   Field XPos:Int,YPos:Int

   Method X(XPos:int=-9999)
	if XPos = -9999 then return self.XPos
	self.XPos = XPos
   End Method

End Type


Its untested, but I was thinking that you would call it like this:
X = MyShip.X() ' get X
MyShip.X( 100 ) ' set X

[edit] looks like I was a little slow and HappyCat have already suggested something similar. I think it would work just fine.