[fpc-devel] for-in-index loop

waldo kitty wkitty42 at windstream.net
Fri Jan 25 19:50:46 CET 2013


On 1/25/2013 11:30, Florian Klämpfl wrote:
> Am 25.01.2013 17:18, schrieb Alexander Klenin:
>> var
>>    a: array [1..5] of Integer = (1, 2, 9, 4, 5);
>>
>> In my proposal, he should write:
>> var
>>    v, i: Integer;
>> begin
>>    for a in a index i do
>>      Writeln(i, ' ', v);
>> end.
>
> In this case I just write
>
> for i:=low(a) to high(a) do
>    writeln(i,' ',a[i]);

that's *exactly* what i was going to write in reply but i'm glad i read on and 
saw that someone else had already done so...

> Works afaik since TP 6.0.

yep! at least that far back... i use it daily, even today as i try to move more 
and more to FPC... the above is also perfect pascal syntax... a simple and easy 
to read and understand flow :)



More information about the fpc-devel mailing list