|
|
|
|
|
by mojuba
844 days ago
|
|
func (o Operation) IsValid() bool {
if o == Unknown {
return false
}
return true
}
Why, oh why don't people just write return o != Unknown
This is so common in the code that I'm seeing on the Internet, on GitHub etc. Is it because people don't understand booleans? |
|
For this example we only have a single condition but as soon as you add more conditions it start to get out of hand.
I prefer the original code because it makes the codebase as a whole easier to read. But I don't think there are any 'hard facts' to support using either of these styles over the other in these simple cases.