First what I am used to (VB):
I create a function:
Function MyMethod(byRef x As String); x = "changed" End Function
If I call this function - with whatever variable - can be a local, can be a property, can be anything, as long as it is the correct type:
And MyVar will have the value of “changed”
In Oxygene I find the following:
method MyMethod(var x: String); begin x := 'changed'; end;
When I call it with:
I get an error.
I have to call it with
This is extra typing - not neccesary, because I already specified the “var” in the method.
And in Oxygene, this only works with local variables and field.
So, to get the 100% equivalent of the VB one-liner. I have to write in Oxygene:
var MyLocal := myVar; MyMethod(var MyLocal); myVar := MyLocal;
So 3 lines of code instead of 1 and an extra keyword in the middle call.
Can this be simplified to just one line of code without extra keywords?