ruby hash transform keys

# Original hash
original_hash = { 'one' => 1, 'two' => 2, 'three' => 3 }

# Transformation using transform_keys method
transformed_hash = original_hash.transform_keys { |key| key.to_sym }

# Output
puts transformed_hash
  1. Declare an original hash with string keys and integer values.
  2. Use the transform_keys method to transform the keys of the original hash.
  3. Inside the block, use to_sym to convert each key from a string to a symbol.
  4. Store the transformed hash in the variable transformed_hash.
  5. Print the transformed hash to the console.