Ruby - Night at the movies - Lesson 9: Please re-write final sentence


#1



https://www.codecademy.com/courses/ruby-beginner-en-0i8v1/0/9?curriculum_id=5059f8619189a5000201fbcb


I was struggling for a long time with "(ruby):45: syntax error, unexpected '!', expecting keyword_end" because the phasing/punctuation of this lesson is confused me.

Ruby makes it easy to remove a movie/rating pair from our hash: we just write movies.delete(title)!

It took me a lot of commenting and rewriting if/else blocks before I finally figured out the ! in the lesson text wasn't actually part of the command. I thought it was in the var.method! syntax we've previously learned is used to apply the change to the variable.

While I appreciate the text is formatted with a grey box - and as I'm writing this I've realised if it were intended the syntax would be var.method!(n) anyway - it's not obvious at a glance and a frustrating block for a Ruby Newbie.

I think it would really improve this lesson for stupid newbies like me if you rewrote that sentence.

Cheers


movies = {
    princess_bride: 4,
}

puts "What would you like to do Dave"
choice = gets.chomp

case choice
when "add"
#    puts "Added!"
    puts "What movie do you want to add Dave"
    title = gets.chomp
    title.gsub!(/ /,"_")
    if movies[title.to_sym] == nil
        puts "What rating do you want to give the movie Dave"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
        puts "Thank you Dave"
    else
        puts "I'm afraid I can't do that Dave"
    end
when "update"
#    puts "Updated!"
    puts "What movie do you want to update Dave"
    title = gets.chomp
    title.gsub!(/ /,"_")
    if movies[title.to_sym] != nil
        puts "What rating do you want to give the movie Dave"
        rating = gets.chomp
        movies[title.to_sym] = rating.to_i
        puts "Thank you Dave"
    else
        puts "I'm afraid I can't do that Dave"
    end
when "display"
#    puts "Movies!"
    movies.each do |movie,rating|
        puts "#{movie}: #{rating}"
    end
when "delete"
#    puts "Deleted!"
    puts "What movie do you want to delete Dave"
    title = gets.chomp
    title.gsub!(/ /,"_")
    if movies[title.to_sym] != nil
        movies.delete(title.to_sym)!
        puts "Thank you Dave"
    else
        puts "I'm afraid I can't do that Dave"
    end
else
    puts "Error!"
end


#2

Thank you for reporting the problem, we recognise this is a bug, however as it does not prevent users from passing the lesson and this is one of the older courses it is unlikely this bug will be fixed. Thank you for taking the time to inform us though, we would like everything to be fixed just as much as you would!