Question about hashes & symbols



I've been working on this movie database program, and I have a question about the original key/value pairs that we put in our initial hash. The example code from 1/10 is

movies = {
Memento: 3,
Primer: 4,
Ishtar: 1

Each key is a symbol and the symbol is made up of only one word. When I have tried to add movie titles that have more than one word, I have received error messages.

For example:
movies = {
Happy Gilmore: 4,
(ruby):1: syntax error, unexpected tLABEL, expecting keyword_do or '{' or '('

Why is it that I can use my 'add' case to create a movie with multiple words and spaces, but I can't create one in my initial hash?

Thanks in advance!


Symbols don't accept spaces in their names.

When you add a movie with a space and convert it to a symbol, it will be added to the hash because the to_s method will replace any space with an underscore ("_").