mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 19:43:44 +00:00
compiler: implement operations on nil hashmaps
* comparing a map against nil * getting the length of a nil map
This commit is contained in:
Vendored
+5
@@ -26,6 +26,11 @@ func main() {
|
||||
readMap(testmap2, "seven")
|
||||
lookup(testmap2, "eight")
|
||||
lookup(testmap2, "nokey")
|
||||
|
||||
// operations on nil maps
|
||||
var nilmap map[string]int
|
||||
println(m == nil, m != nil, len(m))
|
||||
println(nilmap == nil, nilmap != nil, len(nilmap))
|
||||
}
|
||||
|
||||
func readMap(m map[string]int, key string) {
|
||||
|
||||
Vendored
+2
@@ -48,3 +48,5 @@ map read: seven = 7
|
||||
twelve = 12
|
||||
lookup with comma-ok: eight 8 true
|
||||
lookup with comma-ok: nokey 0 false
|
||||
false true 2
|
||||
true false 0
|
||||
|
||||
Reference in New Issue
Block a user