Skip to content

Commit 19b5e02

Browse files
authored
Merge pull request #262 from fatkodima/active_support-exclude
Add section about ActiveSupport's method
2 parents bc83b1a + 5b0e3ff commit 19b5e02

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
@@ -1463,6 +1463,23 @@ pets = %w(cat dog)
14631463
pets.include? 'cat'
14641464
----
14651465

1466+
=== `exclude?` [[exclude]]
1467+
1468+
Prefer Active Support's `exclude?` over Ruby's negated `include?`.
1469+
1470+
[source,ruby]
1471+
----
1472+
# bad
1473+
!array.include?(2)
1474+
!hash.include?(:key)
1475+
!string.include?('substring')
1476+
1477+
# good
1478+
array.exclude?(2)
1479+
hash.exclude?(:key)
1480+
string.exclude?('substring')
1481+
----
1482+
14661483
== Time
14671484

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

0 commit comments

Comments
 (0)