Closed MidimasterSoft closed 2 years ago
Strings are objects and so are passed by reference by default. There is no need for the 'var' keyword.
@Kerntrick
There are two subtly different meanings of the word here. Being a reference is not the same thing as being passed by reference.
String is a reference type, which means that variables to them only contain references instead of the objects themselves. But when passed to a function without Var
, these references will still be passed by value. With Var
, the reference is passed by reference, which means that assignments to the parameter variable will be visible outside the function.
SuperStrict
Framework BRL.StandardIO
Local x:String = "hello"
Print x ' hello
A x
Print x ' hello
B x
Print x ' b
Function A(s:String) ' passed by value
s = "a" ' s works like a regular local variable, does not affect x
End Function
Function B(s:String Var) ' passed by reference
s = "b" ' s refers to x; assigning to s is the same as assigning to x
End Function
I can again observe a strange behavior related to "passed by ByRef" variables. This time it is a combination of a STRING variable send to a function "passed ByRef". Inside the function a SELECT/CASE branch does not compare correct. I observed the bug in DEBUG mode and I can reproduce it always with this example:
without the VAR the SELECT/CASE reacts correct:
Also this works perfect:
Is this related to issue 577? You closed it three days ago...