> On Jul 2, 2023, at 3:25 AM, Steve Litt via fpc-pascal 
> <fpc-pascal@lists.freepascal.org> wrote:
> 
> I tend to put continue statements at or near the top of the block, to
> summarily rule out some obvious irrelevant iterations without all sorts
> of if/then/else nesting. As a practical matter it's more readable and
> more maintainable.

Swift has decided to build this pattern into the language. I kind of like it 
but it's also kind of messy looking and a continue at the top of the block 
often is easier to read for me. In pascal it would look like this:

for item in list where item.value > 10 do
  begin
  end;

Which would be the same as:

for item in list do
  begin
    if item.value <= 10 then
      continue;
  end;

or with traditional for loops but this really looks bad.

for i := 0 to list.Count - 1 where list[i] > 10 do
  begin
  end;

Regards,
Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to