Singleton : Fields vs Globals

BlitzMax Forums/BlitzMax Programming/Singleton : Fields vs Globals

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.

Just playing around, this seems to function just fine.

Type TSingleton
	Global singleton:TSingleton
	Field value:Int
	
	Function Create:TSingleton()
		If singleton = Null Then singleton = New TSingleton
		Return singleton
	End Function
End Type


Local a:TSingleton = TSingleton.Create()
a.value = 100
Local b:TSingleton = TSingleton.Create()
Print b.value