Passing variables by reference?
BlitzMax Forums/BlitzMax Programming/Passing variables by reference?
| ||
I noticed in the documentation it says you can pass a variable by reference like:Local myvar:Int=5 Function myfunction:Int(sameasmyvar Var) sameasmyvar:+2 Return sameasmyvar End Function Print myvar 'Should print 7, right? Ie instead of creating a new variable to pass the parameter into, it actually uses the one that was already defined outside of the function? So you can define a variable as a local outside the function and it will still be used as a Local inside the function? |
| ||
you're not actually running myfunction... Local myvar:Int=5 myfunction(myvar) Print myvar Function myfunction:Int(sameasmyvar Var) sameasmyvar:+2 ' Return sameasmyvar End Function |