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.

Use null instead of setting a specific value (null can be interpreted as an int)
Type test
	Field _X:Int = 10
	
	Method X:Int(val:Int=Null)
	
		If Not val=Null Then
			_X = val
		EndIf
		
		Return _X
		
	End Method
End Type

Local t:test =  New test
Print t.x()
Print t.x(100)