06/10 My code passes, but doesn't print the rest of my if/else


Here is the weird part. My code passes and gives me the go-ahead for the next exercise, but now it doesn't print out anything that's in my if/else statement.....

Here's my code:

case choice
when "add"
puts "Name your new movie!"
title = gets.chomp
if movies[title.intern] = nil
puts "Give it a rating from 0-5"
rating = gets.chomp
movies[rating] = 0
movies[title.intern] = rating.to_i
puts "Okay! Your movie is added to the list!"
puts {"#{title} already exists!"}

Any solutions on why this works but doesn't print out past the name (doesn't include rating section either), would be very helpful thank you.


Does "works" mean printing something? If so, it doesn't "work".

If "works" doesn't have to do with printing, then what is the argument for that it would print something? There would have to be code which carries out actions that add up to something being printed. Would you argue for that there is?

For example, for this program, I would argue that x is given a value that satisfies the condition for executing puts "hello", so therefore this program prints hello (and a newline which puts adds)

x = 4
if x > 2
  puts "hello"


I actually already figured it out on my own. I had put "= nil" instead of ".nil?" but um...thank you anyway I think..?


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