How to divide a hash into two tables based on the key and the value in Ruby?


So I am trying to split a Hash into two Arrays, one with the keys and one with the values.

So far I have:

hash = { Matsumoto: "Ruby", Ritchie: "C", Backus: "Fortran", McCarthy: "Lisp" }

Im able to make an array out of keys or values like so: { |creator, proglang| creator }

But I'm unable to make two arrays, one containing the keys and one containing the values. I've played around with a number of methods and I'm at a loss.

Thank you.

keys, values = hash.keys, hash.values

 > keys
 # => [:Matsumoto, :Ritchie, :Backus, :McCarthy]
 > values
 # => ["Ruby", "C", "Fortran", "Lisp"]