this is my code(golang)
func main() {
names := []string{"1", "2", "3"}
for index, name := range names {
println(index, name)
}
myMap := map[string]string{
"A": "Apple",
"B": "Banana",
"C": "Charlie",
}
for key, val := range myMap {
fmt.Println(key, val)
}
}
and this is result
0 1
B Banana
1 2
2 3
C Charlie
A Apple
func println
func println(args ...Type)
The println built-in function formats its arguments in an implementation-specific way and writes the result to standard error.
func Println
func Println(a ...interface{}) (n int, err error)
fmt.Println formats using the default formats for its operands and writes to standard output.
fmt.Println writes to standard output (stdout) and println writes to standard error (stderr), two different, unsynchronized files.
Map types
A map is an unordered group of elements of one type, called the element type, indexed by a set of unique keys of another type, called the key type.
For statements
A "for" statement specifies repeated execution of a block.
The iteration order over maps is not specified and is not guaranteed to be the same from one iteration to the next.
Maps elements are unordered. The iteration order is not specified.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With