How do I exit a for loop prematurely

I’ve got a for loop iterating through an array of payment records,
gathering comparisons of adjacent records (so a simple find is not what
I need). It works fine, but once I’ve identified a particular set of

circumstances, how do I exit from the for loop?

You can exit a loop by calling break:

i=0
loop do
  i += 1
  next if i < 3
  print i
  break if i > 4
end

produces:

345

Regards,
Rodrigo.