Monkey equivalent of BlitzMax Var?

Monkey Forums/Monkey Programming/Monkey equivalent of BlitzMax Var?

Amon(Posted 2013) [#1]
Does Monkey have an equivalent to BlitzMax's Var?


Beaker(Posted 2013) [#2]
No. You can use a Box or just wrap into a Class Instance tho.


ziggy(Posted 2013) [#3]
what Beaker says.

There are built-in classes for this. This is a small sample that show two different methods to pass an integer by reference (ala BlitzMax var):

Function Main()

	'Method one:
	Local number:Int = 5
	
	'We want to pass number by reference:
	Local container:= New IntObject(number)	
	ByRefFunction(container)
	
	'We retrive the result:
	number = container.value
	
	'We get the result
	Print number
	
	
	'Method 2:
	'We prepare an array to send the data:
	Local data:= New Int[1]
	data[0] = number
	ByRefFunctionTwo(data)
	'We retrieve the data back to the variable
	number = data[0]
	Print number
	
End

Function ByRefFunction(data:IntObject)

	data.value = data.value * 2
	
End

Function ByRefFunctionTwo(data:Int[])
	data[0] = data[0] * 2
End