You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import (
"fmt"
)
funcmain() {
varmmap[int]bool// m := make(map[int]bool)// no panic: false. Zero value if no key. Zero mapfmt.Println(m[0])
fori:=1; i<5; i++ {
// panic: assignment to entry in nil mapm[i] =i%2==0
}
// if panic fixed: prints keys in sorted orderfmt.Println(m)
vartoPrint []intforkey:=rangem {
toPrint=append(toPrint, key)
}
// if panic fixed: prints keys in random orderfmt.Println(toPrint)
}
Interviewers asks about maps internal structure:
Trick of 2 and 3 is iterator starts at random position and stringer sorts elements.
We need to create code sample and questions to check 2 and 3 knowledge.
The text was updated successfully, but these errors were encountered: