DEV Community

Discussion on: Optimizing String Comparisons in Go

Collapse
shogg profile image
shogg • Edited on

I have to be harsh here because of all those if-else-statements returning/assigning bool are burning in my eyes!

instead of this

func compareOperators(a string, b string) bool {
  if a == b {
       return true
    }else {
       return false
    }
}

use this

func compareOperators(a, b string) bool {
  return a == b
}