Populate hash with array keys and default value

hash, ruby

Solution

Do as below :

def solution(keys,default_val)
  Hash[keys.product([default_val])]
end

solution([:key1,:key2],12)  # => {:key1=>12, :key2=>12}

Read `Array#product` and `Kernel#Hash`.

Problem

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?

Original source