From 5e4626c9ba43027ba7bc6d6f6bbee7016512d0e6 Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 23 Mar 2014 00:38:35 +0900 Subject: Hash#{select,select!} support return Enumerator if non block given --- mrblib/hash.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mrblib/hash.rb b/mrblib/hash.rb index cd6ba8935..9dcfb7e94 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -162,6 +162,8 @@ class Hash # 1.9 Hash#select! returns Hash; ISO says nothing. def select!(&b) + return to_enum :select! unless block_given? + keys = [] self.each_key{|k| v = self[k] @@ -178,6 +180,8 @@ class Hash # 1.9 Hash#select returns Hash; ISO says nothing. def select(&b) + return to_enum :select unless block_given? + h = {} self.each_key{|k| v = self[k] -- cgit v1.2.3