PDA

View Full Version : Is there a typo here?



Lima Bean
11-06-2011, 01:48 PM
Just a generic funct :)


function name( arr: array of string):array;
var
I : integer;
begin;
for i := 0 to Len - 1 do
result[i] := arr[i];
end;

nielsie95
11-06-2011, 02:17 PM
You always have to specify a type. "Array" itself wont do. Of course, this type could be a generic type. Generic types still have to be specialized before use, though.

Lima Bean
11-06-2011, 02:20 PM
I guess my question was too broad, let me narrow some. Will the "I" still output to "result[i]". I know the scope is local to the procedure :):)

nielsie95
11-06-2011, 02:29 PM
I don't think I really understand your question :p

Lima Bean
11-06-2011, 02:36 PM
Btw, this is not a trick question :). The code is from mufasatypesutil.pas file

function ConvArr(Arr: array of String): TStringArray; overload;
var
Len : Integer;
I : integer;
begin;
Len := Length(Arr);
SetLength(Result, Len);
for i := 0 to Len - 1 do
result[i] := arr[i];
end;

Zyt3x
11-06-2011, 02:38 PM
What is the question?

Lima Bean
11-06-2011, 02:41 PM
Will the I result to result[i]=arr[i]? Am thinking about inconsistent variables.... Beans are primitive that way :)

Method
11-06-2011, 02:43 PM
The language is case insensitive, so I is the same as i.

Lima Bean
11-06-2011, 02:46 PM
Ty, just had to check to make sure.