Logo

Programming-Idioms

History of Idiom 163 > diff from v7 to v8

Edit summary for version 8 by programming-idioms.org:
New Go implementation by user [programming-idioms.org]

Version 7

2018-06-12, 09:39:08

Version 8

2018-08-03, 20:40:23

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.

Imports
import "fmt"
Code
for i := 0; i+1 < len(list); i += 2 {
	fmt.Println(list[i], list[i+1])
}
Demo URL
https://play.golang.org/p/lh8J17IxE7w