如果在 if 的两个分支中都设置了变量,则可以将其替换为单个 if。
var a int if b { a = 100 } else { a = 10 } |
a := 10 if b { a = 100 } |