[fpc-pascal] Legitimate use of for and break

Hairy Pixels genericptr at gmail.com
Fri Jun 16 15:51:42 CEST 2023



> On Jun 16, 2023, at 6:23 PM, Thomas Kurz via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
> 
> Whether it's elegant is a different question. In my opinion YES because it often gives better readable code than nested "if" statements inside the loop. But I've also read that using "break" is discouraged because it shows a bad choice of the loop range.

This is highly suspect. Doing an early break in loops is the essence of how to do linear searching. No idea who thinks that's a bad idea.

Regards,
Ryan Joseph



More information about the fpc-pascal mailing list