From 5386cd9b9b8770ddb3683687fd1ad0e5bbccae4b Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 23 Mar 2014 00:22:22 +0900 Subject: Hash#each_{key,value} support return Enumerator if non block given --- mrblib/hash.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mrblib') diff --git a/mrblib/hash.rb b/mrblib/hash.rb index 0423f7edc..cd6ba8935 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -69,6 +69,8 @@ class Hash # # ISO 15.2.13.4.10 def each_key(&block) + return to_enum :each_key unless block_given? + self.keys.each{|k| block.call(k)} self end @@ -93,6 +95,8 @@ class Hash # # ISO 15.2.13.4.11 def each_value(&block) + return to_enum :each_value unless block_given? + self.keys.each{|k| block.call(self[k])} self end -- cgit v1.2.3