Learn

Perfect! Our program is really coming along.

You might have wondered how we’re going to get our movies and ratings from the user—which come in as strings—into the hash where we want our movies to be symbols and our ratings to be integers. Built-in Ruby magic to the rescue!

Ruby’s .to_sym method can convert a string to a symbol, and .to_i will convert a string to an integer.

Instructions

1.

Call .to_sym on your title and .to_i on your rating so that your movie titles are stored as symbols in the hash and the associated ratings are stored as integers.

Take this course for free

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

Already have an account?