如果在if的两个分支中都设置了变量,则可以将其替换为单个if。
if
//bad usage var a int if b { a = 100 } else { a = 10 } //good usage a := 10 if b { a = 100 }
Last updated 4 years ago
Was this helpful?