Stuck on a Code Wars Challenge: Complete the solution so that it takes an array of keys and a default value and returns a hash with all keys set to the default value.
My answer results in a parse error:
def solution([:keys, :default_value])
return { :keys => " ", :default_value => " " }
end
Am I missing something to do with returning a hash key with all the keys set to the default value?
Enumerable#injectin Ruby:keys.inject({}) { |h, k| h.merge({k => default_val}) }orkeys.inject({}) { |h, k| h[k] = default_val ; h }.hat the end of the block:keys.each_with_object({}) { |k, h| h[k] = default_val }.