mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Hash#{select,select!} support return Enumerator
if non block given
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user