Go Keyword range

From NovaOrdis Knowledge Base
Revision as of 22:50, 27 March 2016 by Ovidiu (talk | contribs)
Jump to navigation Jump to search

Internal

Overview

range keyword is used to iterate over arrays, slices and maps. It returns two value, on the first position is the index/kyes, and the second position is the value.

var a [5]int
for i, value := range a {
   // i is the index
   // value is the value
}