Thanks to visit codestin.com
Credit goes to github.com

Skip to content

jxub/defaultdict_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

defaultdict_go

Pythonic defaultdict in Golang 🤘

Install

$ go get github.com/jxub/defaultdict_go

🎉💩🔥

Usage

import "github.com/jxub/defaultdict_go" dd

func main() {
    // create a defaultdict with default values of 0,
    // as int() constrictor yields in Python
    d := dd.NewDefaultDict(0)

    // Get and Set works as usual
    d.Set("bitcoin", 14364)
    d.Get("bitcoin") // -> 14364
    
    // getting a not initialized key yields the default value
    d.Get("dentacoin") // -> 0 (oh the irony ;))
}

PR's and other good stuff encouraged! Happy Hacking!

About

Pythonic defaultdict in Golang 🤘

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages