Go Keyword range: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 2: Line 2:


* [[Go_Concepts_-_Lexical_Structure#Keywords|Keywords]]
* [[Go_Concepts_-_Lexical_Structure#Keywords|Keywords]]
* [[Go for#for_Controlled_by_a_.22range.22_Clause|for]]
* <tt>[[Go for#for_Controlled_by_a_.22range.22_Clause|for]]</tt>


=Overview=
=Overview=

Revision as of 03:11, 28 March 2016

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
}