Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -1,16 +1,23 @@
// declare a nil map variable, for maps from string to int
var x map[string] int
var x map[string]int
// make an empty map
x = make(map[string] int)
x = make(map[string]int)
// make an empty map with an initial capacity
x = make(map[string] int, 42)
x = make(map[string]int, 42)
// set a value
x["foo"] = 3
// getting values
y1 := x["bar"] // zero value returned if no map entry exists for the key
y2, ok := x["bar"] // ok is a boolean, true if key exists in the map
// removing keys
delete(x, "foo")
// make a map with a literal
x = map[string] int {
"foo": 2, "bar": 42, "baz": -1,
x = map[string]int{
"foo": 2, "bar": 42, "baz": -1,
}