Commit 5e4626c9 authored by ksss's avatar ksss

Hash#{select,select!} support return Enumerator

if non block given
parent ff666663
...@@ -162,6 +162,8 @@ class Hash ...@@ -162,6 +162,8 @@ class Hash
# 1.9 Hash#select! returns Hash; ISO says nothing. # 1.9 Hash#select! returns Hash; ISO says nothing.
def select!(&b) def select!(&b)
return to_enum :select! unless block_given?
keys = [] keys = []
self.each_key{|k| self.each_key{|k|
v = self[k] v = self[k]
...@@ -178,6 +180,8 @@ class Hash ...@@ -178,6 +180,8 @@ class Hash
# 1.9 Hash#select returns Hash; ISO says nothing. # 1.9 Hash#select returns Hash; ISO says nothing.
def select(&b) def select(&b)
return to_enum :select unless block_given?
h = {} h = {}
self.each_key{|k| self.each_key{|k|
v = self[k] v = self[k]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment