p (1..10).inject{ |r,e| p [r,e]; r*2} # Result: # [1, 2] # [2, 3] # [4, 4] # [8, 5] # [16, 6] # [32, 7] # [64, 8] # [128, 9] # [256, 10] # 512
View Source