9/10


#1

movies = {
"Pursuit of happyness".to_sym => 10
}
puts "movie?"
choice = gets.chomp

case choice

when "add"

puts "What is the movie title?"
title = gets.chomp
puts "What would you rate this title?"
rating = gets.chomp
if movies[title.to_sym] == nil
    movies[title.to_sym] = rating.to_i

puts "The #{title} and #{rating} pair was added"
else
puts "Movie already exist in db "
end

when "update"
puts "Movie Title?"
title = gets.chomp
if movies[title] == nil
puts "movie isnt in your collection"
else
puts "New Rating: "
rating = gets.chomp
end

when "display"
movies.each do |k,v|
puts "#{k}: #{v}"
end

when "delete"
puts "Whats the title?"
if movies[title.to_sym].nil?
puts "Movie doesnt exist in the dhatabase"
else
movies.delete(title.to_sym)

end
else
puts "Error!"
end

how come when I use the delete command it passes WITHOUT asking me for the title of the movie?


#2

Because you don't ask the user for input with gets.chomp, so obviously the code not going to stop and will execute everything inside the "delete" case without interruption.