There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Is there a way of continuing to ask the user for input? So for example in this exercise, once you’ve finished writing the code and you test it, if you write ‘display’, it displays all the movies. But what if you wanted to then add a book as well? How would you continue to get user input?
Thanks!
Films are generally given proper names, and many have more than one word in the title. All we need to do is let Ruby convert them.
your command:
add
Movie title:
A Night At The Movies
Movie rating:
4
A Night At The Movies added with rating 4.
puts movies
{:Crash=>4, :Babel=>4, :"A Night to Remember"=>2, :"A Night At The Movies"=>4}
Arbitrarily altering the inputs affects natural search. Ruby can handle multiple word names.
i don’t really have an opinion other that already stated. If the user inputs a proper name, we should endeavor to preserve it as inputted without alteration. string.to_sym is something we can convert back to the original string. If we alter it, then we lose the naturalness of the input, and cannot feasibly convert back to what it was initially, especially if the case is changed.
Whenever I used this code the program did not recognize the title as already in the hash unless I included the underscore between each word of the title as it was written in symbol
Hello, everyone!
I hope you’re fine.
I think this exercise can be improved by adding the .capitalize() to the title = gets.chomp because when you enter a movie name in lowercase (memento) it says Movie not found!. I know it is only an exercise but I think it can be better by adding this.
Thanks