Code Editor
Learn
A Night at the Movies

Setting Up

First things first: let's create a hash to hold our movies and their ratings, and let's prompt the user for input so we can eventually store movie/ratings pairs in our hash.

favorite_foods = { 'vegetable' => 'broccoli' } puts "Do you like coding in Ruby?" answer = gets.chomp
  1. A hash is a way of storing data by a specifiable key, as opposed to an array which can only sort using numbers. It is created like { } above.
  2. puts asks a question on the command line, here we ask if you like coding in Ruby.
  3. In order to get the user input, we have to call .chomp on gets
Report a Bug
If you see a bug or any other issue with this page, please report it here.