Learn
A Night at the Movies
Error! Error!

All right! We’re nearly done with the “add” part of our case. The final thing we’ll want to do is perform a check to see whether the movie to be added is already in the hash.

To do this, we’ll add an if/else statement.

Instructions

1.

Add an if/else statement to the add branch of your case. If the movie isn’t already in the hash (that is, if movies[title.to_sym] is nil), it should add the movie/rating pair; otherwise, it should puts that the movie already exists and not add anything to the hash. Make sure to test it!

Folder Icon

Take this course for free

Already have an account?