Nov
26
Returning Function as Array in Delphi
Do you wonder how to do vector operation in Delphi? No, of course, :).
We could go like this.
function tform1.adv(a,b:real):real; begin adv:=a+b; end;
The problem is the return is real, which is single value only. We want a and b as vector. Wait...
How we define vector in Delphi? I don't know. I used to treat a vector in Delphi as array. So I coded it like this
var a,b:array[0..1]of real;
So far I had no problem. Lately, I am going crazy with overuse functions in Delphi, and trying operating vectors using function too.
But if I write the code like this
function tform1.adv(a,b:array[0..1]of real):real; begin adv:=a[0]+b[0]; {a[1]+b[1]?} end;
It will only return one value. So I improvised by modify it