A
ara howard
is this consistent with other peoples stdlib hacks?
class Hash
def slice *keys, &block
if block
each do |key, val|
boolean = block.call(key, val)
keys << key if boolean
end
end
hash = self
keys.inject({}){|returned, key| returned.update key => hash[key]}
end
end
??
a @ http://codeforpeople.com/
class Hash
def slice *keys, &block
if block
each do |key, val|
boolean = block.call(key, val)
keys << key if boolean
end
end
hash = self
keys.inject({}){|returned, key| returned.update key => hash[key]}
end
end
??
a @ http://codeforpeople.com/