Skip to content

Commit ca45b25

Browse files
committed
Merge pull request #4 from mdsol/if_condition_equalsequals_true
Avoid comparing booleans to boolean constants.
2 parents fd77f39 + 3fb6c06 commit ca45b25

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,23 @@ You can generate a PDF or an HTML copy of this guide using
249249
# good
250250
arr.each { |elem| puts elem }
251251
```
252+
* Avoid comparing booleans to boolean constants.
253+
254+
```Ruby
255+
# bad
256+
if condition == true
257+
258+
# good
259+
if condition
260+
261+
# bad
262+
options[:verbose] = true
263+
puts "Loading…" unless options[:verbose] == false
264+
265+
# good
266+
options[:silent] = false
267+
puts "Loading…" unless options[:silent]
268+
```
252269
253270
* Never use `then` for multi-line `if/unless`.
254271

0 commit comments

Comments
 (0)