compiler: support comma-ok in map lookup

This commit is contained in:
Ayke van Laethem
2018-10-20 17:54:16 +02:00
parent da89464a63
commit 7c2a6169b0
5 changed files with 33 additions and 15 deletions
+6
View File
@@ -24,6 +24,8 @@ func main() {
readMap(testmap2, "ten")
delete(testmap2, "six")
readMap(testmap2, "seven")
lookup(testmap2, "eight")
lookup(testmap2, "nokey")
}
func readMap(m map[string]int, key string) {
@@ -33,3 +35,7 @@ func readMap(m map[string]int, key string) {
println(" ", k, "=", v)
}
}
func lookup(m map[string]int, key string) {
value, ok := m[key]
println("lookup with comma-ok:", key, value, ok)
}