Skip to content

Commit c252d36

Browse files
author
Bozhidar Batsov
committed
Reword !! rule
1 parent a15f631 commit c252d36

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -634,20 +634,25 @@ Never use `::` for regular method invocation.
634634
x = !something
635635
```
636636
637-
* Avoid the use of `!!` to convert an object to a `boolean` value.
637+
* Avoid the use of `!!`.
638638
639639
```Ruby
640-
# bad - doesn't work properly with boolean values
640+
# bad
641641
x = 'test'
642-
!!x # => true
642+
# obscure nil check
643+
if !!x
644+
# body omitted
645+
end
646+
643647
x = false
648+
# double negation is useless on booleans
644649
!!x # => false
645650
646-
# good - works for all values (+ it's more readable)
651+
# good
647652
x = 'test'
648-
!x.nil? # => true
649-
x = false
650-
!x.nil? # => true
653+
if !x.nil?
654+
# body omitted
655+
end
651656
```
652657
653658
* The `and` and `or` keywords are banned. It's just not worth

0 commit comments

Comments
 (0)