Board index » delphi » Would be nice if Delphi could do this

Would be nice if Delphi could do this


2008-05-23 11:40:00 PM
delphi34
type
TRec = record
f1 : integer;
f2 : integer;
f3 : integer;
end;
var
a : array of TRec = ((f1:1;f2:2;f3:3),(f1:4;f2:5;f3:6));
//a1 : array[0..1] of TRec = ((f1:1;f2:2;f3:3),(f1:4;f2:5;f3:6));
begin
end.
Currently Delphi does not understand this (you need to specify size of
array like for a1), but would be nice if it could.
BR
Eriks
 
 

Re:Would be nice if Delphi could do this

Quote
Currently Delphi does not understand this (you need to specify size of
array like for a1), but would be nice if it could.
Agreed. That would be handy. I don't use this mechanism a lot, but I
definitely remember times where I didn't have the number of array elements
right and had to figure that out which was an, albeit minor, pain.
 

Re:Would be nice if Delphi could do this

Michael C. writes:
Quote
nospam writes:
>type
>TRec = record
>f1 : integer;
>f2 : integer;
>f3 : integer;
>end;
>
>var
>a : array of TRec = ((f1:1;f2:2;f3:3),(f1:4;f2:5;f3:6));

I agree with what your saying but
I prefer this:

a : array of TRec = (1,2,3), (4,5,6);
You don't have that with static arrays either. And the checks that
occur if you must type the field names are a safety measure.
--
Rudy Velthuis [TeamB] www.teamb.com
"Don't be so humble - you are not that great."
-- Golda Meir (1898-1978) to a visiting diplomat