Skip to content

Commit b9a4304

Browse files
committed
Fix misleading comment in logicalOperators.go; expand on others
1 parent 285c127 commit b9a4304

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

logicalOperators.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func logicalAndElseBranchAlwaysBad2() {
7575
if errorSource() == ErrNone && someOtherCondition() {
7676
doSomething()
7777
} else {
78-
// Bad: On error we may enter either branch, but neither one returns.
78+
// Bad: there is no return statement at all.
7979
insteadOfReturn()
8080
}
8181
doSomething()
@@ -85,7 +85,7 @@ func logicalAndElseBranchAlwaysBad2() {
8585
func logicalAndThenBranchGood() {
8686

8787
if someOtherCondition() && errorSource() != ErrNone {
88-
// Good: whenever an error is indicated we return.
88+
// Good: whenever an error is indicated we return (note errorSource() is not called until someOtherCondition() passes)
8989
return
9090
}
9191
doSomething()
@@ -95,7 +95,7 @@ func logicalAndThenBranchGood() {
9595
func logicalAndElseBranchGood() {
9696

9797
if someOtherCondition() && errorSource() == ErrNone {
98-
// Good: whenever an error is indicated we return.
98+
// Good: whenever an error is indicated we return (note errorSource() is not called until someOtherCondition() passes)
9999
doSomething()
100100
} else {
101101
return
@@ -154,7 +154,7 @@ func logicalOrThenBranchAlwaysBad() {
154154
func logicalOrThenBranchGood() {
155155

156156
if someOtherCondition() || errorSource() != ErrNone {
157-
// Good: whenever an error is indicated we return.
157+
// Good: whenever an error is indicated we return. (note errorSource() is not called until someOtherCondition() fails)
158158
return
159159
}
160160
doSomething()
@@ -164,7 +164,7 @@ func logicalOrThenBranchGood() {
164164
func logicalOrElseBranchGood() {
165165

166166
if someOtherCondition() || errorSource() == ErrNone {
167-
// Good: whenever an error is indicated we return.
167+
// Good: whenever an error is indicated we return. (note errorSource() is not called until someOtherCondition() fails)
168168
doSomething()
169169
} else {
170170
return

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy