1
0
mirror of https://github.com/golang/go synced 2024-11-25 03:17:58 -07:00
go/doc/progs/go1.go
Rob Pike 2fa987b6cd doc/go1: map deletion
This CL is in part a proposal for how to write these sections:
- Brief discussion of change
- No attempt to analyze the thinking about it
- Old code
- New code, runnable if possible
- How to update old programs

R=golang-dev, remyoudompheng, gri, adg
CC=golang-dev
https://golang.org/cl/5454044
2011-12-07 16:11:17 -08:00

23 lines
446 B
Go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains examples to embed in the Go 1 release notes document.
package main
import "log"
func main() {
mapDelete()
}
func mapDelete() {
m := map[string]int{"7": 7, "23": 23}
k := "7"
delete(m, k)
if m["7"] != 0 || m["23"] != 23 {
log.Fatal("mapDelete:", m)
}
}