Skip to content
Permalink
Browse files

Merge pull request #568 from kostya/partition

array#partition
  • Loading branch information
alex committed Mar 31, 2013
2 parents 9167847 + 1d11e9a commit 720a707d0617793b2520bbfe765d62ad80dc081a
@@ -176,6 +176,15 @@ def max
end
end

def partition(&block)
return self.enum_for(:partition) unless block
a, b = [], []
self.each do |e|
block.call(e) ? a.push(e) : b.push(e)
end
[a, b]
end

def count(*args, &block)
c = 0
if args.empty?

This file was deleted.

@@ -1,3 +1 @@
fails:Enumerable#partition returns two arrays, the first containing elements for which the block is true, the second containing the rest
fails:Enumerable#partition returns an Enumerator if called without a block
fails:Enumerable#partition gathers whole arrays as elements when each yields multiple

0 comments on commit 720a707

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