Let's say I have
some_value = 23
I use the integer and the .times to loop.
Inside the iteration, is there an easy way, without keeping a counter, to see what iteration the loop is currently in?
Let's say I have
some_value = 23
I use the integer and the .times to loop.
Inside the iteration, is there an easy way, without keeping a counter, to see what iteration the loop is currently in?
Yes, just have your block accept an argument:
some_value.times{|i| ... }