Skip to content

Instantly share code, notes, and snippets.

@Medeah
Created March 10, 2013 08:22
Show Gist options
  • Save Medeah/5127618 to your computer and use it in GitHub Desktop.
Save Medeah/5127618 to your computer and use it in GitHub Desktop.
A Tour of Go 40: Exercise: Maps
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
wordCount := make(map[string]int)
for _, word := range strings.Fields(s) {
wordCount[word]++
}
return wordCount
}
func main() {
wc.Test(WordCount)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment