diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-23 02:11:54 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-23 02:11:54 +0900 |
| commit | 76b2ba886a1472932f37dbe5759725d23be88301 (patch) | |
| tree | 82d268971149b34f6a7d34f2cfb170f89247f055 /mrblib | |
| parent | 539d9cb855e396047cccccc84ffc88825d77bdf7 (diff) | |
| parent | 5386cd9b9b8770ddb3683687fd1ad0e5bbccae4b (diff) | |
| download | mruby-76b2ba886a1472932f37dbe5759725d23be88301.tar.gz mruby-76b2ba886a1472932f37dbe5759725d23be88301.zip | |
Merge pull request #1916 from ksss/hash-enumerator
Hash#each_{key,value} support return Enumerator if non block given
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/hash.rb | 4 |
1 files changed, 4 insertions, 0 deletions
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 |
