I need to check if the same key exists in two maps:
if v1, ok1 := map1["aaa"]; ok1 {
...
}
if v2, ok2 := map2["aaa"]; ok2 {
...
}
Is it possible to join these two conditions into one? I managed to do something like this:
v1, ok1 := map1["aaa"]
v2, ok2 := map2["aaa"]
if ok1 && ok2 {
...
}
but I'm curious whether it (assigning and checking) can be done in one if
condition.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…