Learn

Converting between strings and symbols is a snap.

:sasquatch.to_s # ==> "sasquatch" "sasquatch".to_sym # ==> :sasquatch

The .to_s and .to_sym methods are what you’re looking for!

Instructions

1.

We have an array of strings we’d like to later use as hash keys, but we’d rather they be symbols.

  1. Create a new variable, symbols, and store an empty array in it.
  2. Use .each to iterate over the strings array.
  3. For each s in strings, use .to_sym to convert s to a symbol and use .push to add that new symbol to symbols.
  4. Print the symbols array.

Check the hint for a more information on how to use .each and .push.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?