I’m trying to do repeat a code block, but have something happen every 5th time.
In English:
Do this 30 times, every 5th time take an additional step
My Ruby so far:
6.times do
5.times do
#standard step
end
#perform additional step
end
but I wondered if there was a clever way to do it?
mostly you do “every nth time” problems with a modulo like this: