Skip to content
Permalink
Browse files

Merge pull request #588 from kostya/detect

enumerable#detect more tags
  • Loading branch information
alex committed Apr 9, 2013
2 parents 81ab361 + cf3efad commit 8aed98f553cbca459bf225d07d8ad024c5bf6cdc
Showing with 2 additions and 10 deletions.
  1. +2 −2 lib-topaz/enumerable.rb
  2. +0 −4 spec/tags/core/enumerable/detect_tags.txt
  3. +0 −4 spec/tags/core/enumerable/find_tags.txt
@@ -119,11 +119,11 @@ def to_a
alias entries to_a

def detect(ifnone = nil, &block)
return self.enum_for(:detect) unless block
return self.enum_for(:detect, ifnone) unless block
self.each do |o|
return o if block.call(o)
end
return ifnone
ifnone.is_a?(Proc) ? ifnone.call : ifnone
end
alias find detect

@@ -1,6 +1,2 @@
fails:Enumerable#detect returns the value of the ifnone proc if the block is false
fails:Enumerable#detect calls the ifnone proc only once when the block is false
fails:Enumerable#detect calls the ifnone proc when there are no elements
fails:Enumerable#detect passes through the values yielded by #each_with_index
fails:Enumerable#detect passes the ifnone proc to the enumerator
fails:Enumerable#detect gathers whole arrays as elements when each yields multiple
@@ -1,6 +1,2 @@
fails:Enumerable#find returns the value of the ifnone proc if the block is false
fails:Enumerable#find calls the ifnone proc only once when the block is false
fails:Enumerable#find calls the ifnone proc when there are no elements
fails:Enumerable#find passes through the values yielded by #each_with_index
fails:Enumerable#find passes the ifnone proc to the enumerator
fails:Enumerable#find gathers whole arrays as elements when each yields multiple

0 comments on commit 8aed98f

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