Skip to content
Permalink
Browse files

Merge pull request #591 from kachick/implement-enumerable-each_with_o…

…bject

Implement Enumerable#each_with_object
  • Loading branch information
alex committed Apr 10, 2013
2 parents de8f9cf + 4109da9 commit d8f40978c7aa5d306f1c86fce3692c7916a573da
@@ -22,3 +22,4 @@ Authors
* Robin Schreiber
* Jan Stępień
* Jeremy Thurgood
* Kenichi Kamiya
@@ -53,6 +53,14 @@ def each_with_index(&block)
end
end

def each_with_object(memo, &block)
return self.enum_for(:each_with_object, memo) unless block
self.each do |elm|
yield elm, memo
end
memo
end

def all?(&block)
self.each do |obj|
return false unless (block ? block.call(obj) : obj)
@@ -1,3 +1 @@
fails:Enumerable#each_with_object passes each element and its argument to the block
fails:Enumerable#each_with_object returns an enumerator if no block
fails:Enumerable#each_with_object gathers whole arrays as elements when each yields multiple

This file was deleted.

0 comments on commit d8f4097

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