logo-MindMajix
PostGoLangGoLang
J
James ROBERT

Posted on 21st June 2024|15 views

0
votes

Golang Iterate Over Map

How can I iterate over a map by using for loop in Golang?

1 answers
Answers
P
Lakshmi sowjanya

Posted on 21st June 2024| views

You can refer this example:

package main

 import "fmt"

 func main() {

var employee = map[string]int{"Mahi": 100, "Rohit": 85,"Rahul": 80, "Hardhik": 70}

    for key, element := range employee {

        fmt.Println("Key:", key, "=>", "Element:", element)

    }

}

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo

  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos
Name
Course *
Email *
Phone Number