Curious about when to put .to_i and .intern


This is the right code, but I want to know if instead of movies[title.intern] = rating.to_i,
I could write it like this: title = gets.chomp.intern
and rating = gets.chomp.to_i

Is there a difference? It still runs, but it wouldn't let me pass.

case choice
when "add"
  puts "What movie do you want to add?"
  title = gets.chomp.downcase
  puts "On a scale of 1-5, how would you rate #{title}"
  rating = gets.chomp
  movies[title.intern] = rating.to_i
  movies["#{title}"] = rating


You mention two things but seem to be talking about four


They're all different, why would they not be? A start would be to consider what title and rating are, and then look up what those methods do


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