Skip to content

Commit 5b0e3ff

Browse files
committed
Add section about ActiveSupport's method
1 parent 85a902d commit 5b0e3ff

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,23 @@ pets = %w(cat dog)
14311431
pets.include? 'cat'
14321432
----
14331433

1434+
=== `exclude?` [[exclude]]
1435+
1436+
Prefer Active Support's `exclude?` over Ruby's negated `include?`.
1437+
1438+
[source,ruby]
1439+
----
1440+
# bad
1441+
!array.include?(2)
1442+
!hash.include?(:key)
1443+
!string.include?('substring')
1444+
1445+
# good
1446+
array.exclude?(2)
1447+
hash.exclude?(:key)
1448+
string.exclude?('substring')
1449+
----
1450+
14341451
== Time
14351452

14361453
=== Time Zone Config [[tz-config]]

0 commit comments

Comments
 (0)