Unverified Commit 469dbeb4 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4624 from shuujii/enumerable-reject-etc.-should-return-Enumerable-without-block

`Enumerable#reject`, etc. should return `Enumerable` without block
parents 496a2c32 9f18aced
...@@ -73,6 +73,8 @@ module Enumerable ...@@ -73,6 +73,8 @@ module Enumerable
# #
# ISO 15.3.2.2.4 # ISO 15.3.2.2.4
def detect(ifnone=nil, &block) def detect(ifnone=nil, &block)
return to_enum :detect, ifnone unless block
self.each{|*val| self.each{|*val|
if block.call(*val) if block.call(*val)
return val.__svalue return val.__svalue
...@@ -282,6 +284,8 @@ module Enumerable ...@@ -282,6 +284,8 @@ module Enumerable
# #
# ISO 15.3.2.2.16 # ISO 15.3.2.2.16
def partition(&block) def partition(&block)
return to_enum :partition unless block
ary_T = [] ary_T = []
ary_F = [] ary_F = []
self.each{|*val| self.each{|*val|
...@@ -302,6 +306,8 @@ module Enumerable ...@@ -302,6 +306,8 @@ module Enumerable
# #
# ISO 15.3.2.2.17 # ISO 15.3.2.2.17
def reject(&block) def reject(&block)
return to_enum :reject unless block
ary = [] ary = []
self.each{|*val| self.each{|*val|
ary.push(val.__svalue) unless block.call(*val) ary.push(val.__svalue) unless block.call(*val)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment