Logo

Programming-Idioms

History of Idiom 163 > diff from v1 to v2

Edit summary for version 2 by steenslag:
New Ruby implementation by user [steenslag]

Version 1

2017-07-31, 16:33:42

Version 2

2017-08-16, 15:57:40

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Idiom #163 Print list elements by group of 2

Print all the list elements, two by two, assuming list length is even.

Code
list.each_slice(2){|slice| p slice}
Demo URL
http://ideone.com/IpHiJ1