by adamrt · 1y ago · 0 comments
if err == nil { // inverted
return err
}It’s usually pretty obvious why: eg
if err == nil {
// we can exit early because we don’t need to keep retrying
But it at least saves me having to double check the logic of the code each time I reread the code for the first time in a while.Works especially well in languages that can make assignments in if statements, e.g:
if foo = 42 { }
if !(err != nil) {would be clearer, I think. Seems like it's the same but would color differently in my editor.