Error! Error!


Guys, I keep getting this message: undefined method `to' for "random title":String

This is my code:

movies = {
Lebowsky: 5,
Pulp: 5,
Donnie: 5,
Foundamentals: 4


puts "Chose and action"
choice = gets.chomp

case choice
when "add"
puts "Type a title"
title = gets.chomp
if movies[].nil?
puts "Please, rate this movie"
rating = gets.chomp
movies[title.to_sym] = rating.to_i
puts "#{title} has been added with a rating of #{rating}."
puts "That's already in our database!"

when "update"
puts "Updated"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
puts "Error!"


Did you mean to call a method named to?
If not, search your code for where you do that and change it to what you meant


That was the stupidest mistake ever :slight_smile:


The mistake or not fixing it? We make mistakes, we just gotta find them later, and error messages are there to say what's wrong so we gotta read them.

A good start is usually verifying the problem so you know you're chasing the right thing, and then consider why it shouldn't have happened - because that reason probably says which part of the code isn't doing its job


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.