Ruby get object keys as array December 27, 2022 by Tarik hash = {"apple" => "fruit", "carrot" => "vegetable"} array = hash.keys #=> ["apple", "carrot"] it’s that simple