12/15 Hashes and Symbols - Syntax Error

Trying to convert a hash rocket to 1.9 hash syntax and I can’t see what I’m doing wrong…

movies = Hash.new
movies = { Django Unchained: “Starring Jamie Foxx”,
Inglourious Basterds: “Starring Brad Pitt”,
Pulp Fiction: “Starring Samuel L Jackson”

Error message says “Oops, try again. Did you create a variable called movies?”
(ruby):1: syntax error, unexpected tLABEL, expecting keyword_do or ‘{’ or ‘(’
movies = { Django Unchained: “Starring Jamie Foxx”,
(ruby):1: syntax error, unexpected ‘,’, expecting $end

Can anyone shed any light?

either use hash literal notation

new_hash = { "one" => 1 }

or hash constructor notation:

new_hash = Hash.new

now you’ve mixed

and you can’t have a space for key name if you use hash literal notation

go to that lesson where you learned about it

So my hash rocket on 11/15 was as follows -
movies = {
:“Django Unchained” => “Starring Jamie Foxx”,
:“Inglourious Basterds” => “Starring Brad Pitt”,
:“Pulp Fiction” => “Starring Samuel L Jackson”,

which worked but when I updated it to 1.9 hash syntax in 12/15 like this -

movies = {
Django Unchained: “Starring Jamie Foxx” ,
Inglourious Basterds: “Starring Brad Pitt” ,
Pulp Fiction: “Starring Samuel L Jackson”

it won’t work… I’m sure I’m just being really slow, but I can’t see what’s wrong with it. I added ‘Hash.new’ as I thought that might be the problem…
Tried putting the key in quotations as well but that didn’t work.

so you can do Django_Unchained instead of Django Unchained

Also see this lesson for Hash.new

1 Like

the space!!! Thank you!