In php you can just do $associative_array_keys = array_keys($associative_array)
Is there a function to get all hash keys in ruby?
I'm currently mapping my hashes and returning the keys: my_hash_keys = my_hash.map{|k,v| k}
Is there a better solution?
You can call .keys
on a Hash to get an array of keys back.
See: Hash#keys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With