From 9f18aced9f4d3c39ba6a5e10c6856c7fc9009714 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Sat, 10 Aug 2019 22:18:54 +0900 Subject: `Enumerable#reject`, etc. should return `Enumerable` without block --- mrblib/enum.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mrblib/enum.rb b/mrblib/enum.rb index fe40b4d27..15687e159 100644 --- a/mrblib/enum.rb +++ b/mrblib/enum.rb @@ -73,6 +73,8 @@ module Enumerable # # ISO 15.3.2.2.4 def detect(ifnone=nil, &block) + return to_enum :detect, ifnone unless block + self.each{|*val| if block.call(*val) return val.__svalue @@ -282,6 +284,8 @@ module Enumerable # # ISO 15.3.2.2.16 def partition(&block) + return to_enum :partition unless block + ary_T = [] ary_F = [] self.each{|*val| @@ -302,6 +306,8 @@ module Enumerable # # ISO 15.3.2.2.17 def reject(&block) + return to_enum :reject unless block + ary = [] self.each{|*val| ary.push(val.__svalue) unless block.call(*val) -- cgit v1.2.3