1func buildIndex(names []string) map[string]int {
2 var index map[string]int
3 for i, name := range names {
4 index[name] = i
5 }
6 return index
7}
no lines flagged
#065PracticeEasy8 min · 50 XP
Writing to a Nil Map Panics
This function panics at runtime when adding the first entry to a freshly declared map.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.