RUBY-265 semantics should == Hash#reject!
This commit is contained in:
parent
d0a4483713
commit
af6552ed3c
@ -125,11 +125,11 @@ module BSON
|
||||
end
|
||||
|
||||
def delete_if(&block)
|
||||
self.each { |k,v|
|
||||
self.each do |k,v|
|
||||
if yield k, v
|
||||
delete(k)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def reject(&block)
|
||||
@ -139,7 +139,14 @@ module BSON
|
||||
end
|
||||
|
||||
def reject!(&block)
|
||||
delete_if(&block)
|
||||
changed = false
|
||||
self.each do |k,v|
|
||||
if yield k, v
|
||||
changed = true
|
||||
delete(k)
|
||||
end
|
||||
end
|
||||
changed ? self : nil
|
||||
end
|
||||
|
||||
def clear
|
||||
|
@ -189,7 +189,8 @@ class OrderedHashTest < Test::Unit::TestCase
|
||||
|
||||
def test_reject_bang
|
||||
@oh.reject! { |k, v| k == 'z' }
|
||||
assert !@ok.keys.include?('z')
|
||||
assert !@oh.keys.include?('z')
|
||||
assert_nil @oh.reject! { |k, v| k == 'z' }
|
||||
end
|
||||
|
||||
def test_clone
|
||||
|
Loading…
Reference in New Issue
Block a user