Skip to content

Latest commit

 

History

History
30 lines (24 loc) · 317 Bytes

else-unnecessary.md

File metadata and controls

30 lines (24 loc) · 317 Bytes

Unnecessary Else

If a variable is set in both branches of an if, it can be replaced with a single if.

BadGood
var a int
if b {
  a = 100
} else {
  a = 10
}
a := 10
if b {
  a = 100
}