diff options
| author | ksss <[email protected]> | 2014-03-23 00:22:22 +0900 |
|---|---|---|
| committer | ksss <[email protected]> | 2014-03-23 00:22:22 +0900 |
| commit | 5386cd9b9b8770ddb3683687fd1ad0e5bbccae4b (patch) | |
| tree | da65429ff31777775baa2728741e7e468b1ac3a8 /mrblib | |
| parent | 7182ef6358f0bdebfd1f949f89b8840e2042a394 (diff) | |
| download | mruby-5386cd9b9b8770ddb3683687fd1ad0e5bbccae4b.tar.gz mruby-5386cd9b9b8770ddb3683687fd1ad0e5bbccae4b.zip | |
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 |
