How should I use each_with_object on Hashes?

I would like to use each_with_object on a hash but can't figure out how I should use it. Here is what I have:

hash = {key1: :value1, key2: :value2}
hash.each_with_object([]) { |k, v, array| array << k }

NoMethodError: undefined method `<<' for nil:NilClass

Is it possible to use each_with_object on hashes? If yes, what is the syntax?


Use ():

hash.each_with_object([]) { |(k, v), array| array << k }