- Updated Ruby snippet for loops