mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
compiler: support comma-ok in map lookup
This commit is contained in:
Vendored
+6
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user