Skip to content
Permalink
Browse files

Merge pull request #569 from kostya/select_i

array#select!, keep_if
  • Loading branch information
alex committed Apr 19, 2013
2 parents 7209ea0 + 440d34e commit 6f5076cc0ef5fc7f2c5225014480ccc990abab17
Showing with 13 additions and 6 deletions.
  1. +13 −0 lib-topaz/array.rb
  2. +0 −3 spec/tags/core/array/keep_if_tags.txt
  3. +0 −3 spec/tags/core/array/select_tags.txt
@@ -97,6 +97,19 @@ def compact!
reject! { |obj| obj.nil? }
end

def select!(&block)
return self.enum_for(:select!) unless block
new_arr = self.select(&block)
if new_arr.size != self.size
self.replace(new_arr)
self
end
end

def keep_if(&block)
self.select!(&block) || self
end

def reject!(&block)
return self.enum_for(:reject!) unless block
prev_size = self.size

This file was deleted.

This file was deleted.

0 comments on commit 6f5076c

Please sign in to comment.
You can’t perform that action at this time.