Var
BlitzMax Forums/BlitzMax Beginners Area/Var
| ||
Hello, for serving the keyword Var ?. |
| ||
SuperStrict Framework Brl.StandardIO Function FunctionA:int() local valueB:int = 10 FunctionB(valueB) print valueB local valueC:int = 10 FunctionC(valueC) print valueC End Function Function FunctionB:int(variable:int var) variable = variable * 2 End Function Function FunctionC:int(variable:int) variable = variable * 2 End Function functionA() For complex types this differs (they are passed "by reference" already). bye Ron |
| ||
Yep. Primitive variables types (Int, Float, etc) are usually passed by value (i.e. a copy of their value is passed into a function). With "Var", you can pass the variable by its reference in memory, allowing you to change the value of the variable within another function. |
| ||
Local n:Int = 100 Function C(n Var) n = 500 End Function c(n) Print n Thanks You. |