Skip to content

Commit

Permalink
Work around broken #eql?, #hash in gemified sorted_set
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynetics committed Jan 9, 2021
1 parent 387c352 commit a077b62
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/character_set/ruby_fallback/set_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def #{mthd}(enum, &block)
end

%i[<< add add? clear collect! delete delete? delete_if
each filter! hash map! keep_if reject!
each filter! map! keep_if reject!
select! subtract].each do |mthd|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{mthd}(*args, &block)
Expand Down Expand Up @@ -83,7 +83,13 @@ def ==(other)

def eql?(other)
return false unless other.is_a?(self.class)
@__set.eql?(other.instance_variable_get(:@__set))
# revert if https://github.com/knu/sorted_set/issues/3 is resolved
hash == other.hash
end

# revert if https://github.com/knu/sorted_set/issues/3 is resolved
def hash
@__set.to_a.hash
end

def initialize_dup(orig)
Expand Down

0 comments on commit a077b62

Please sign in to comment.