-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In Ruby 2.4,
Set#===
is harmonized with Ruby 2.5+ to call include?
- Loading branch information
1 parent
e9a16e9
commit 5b0eb14
Showing
4 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
test = :foo | ||
case test | ||
when Set[:foo] | ||
# ok, RUBY_VERSION > 2.4 | ||
else | ||
# Harmonize `Set#===` | ||
class Set | ||
alias === include? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
# rubocop:disable RSpec/DescribeClass, Style/CaseEquality | ||
RSpec.describe 'Set#===' do | ||
it 'tests for inclusion' do | ||
expect(Set[1, 2, 3] === 2).to eq true | ||
end | ||
end | ||
# rubocop:enable RSpec/DescribeClass, Style/CaseEquality |