All aboard the hash rocket, or maybe not?please help

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<In what way does your code behave incorrectly? Include ALL error messages.>

please help i dunno what is wrong with my code: ```

movies = Hash.new{
:primer => “Awesome”,
:memento => “Not as good the 2nd time”,
}
here is the problem:
(ruby):1: syntax error, unexpected tASSOC, expecting ‘}’
:primer => “Awesome”,
^
(ruby):1: syntax error, unexpected ‘,’, expecting ‘}’
(ruby):2: syntax error, unexpected ‘,’, expecting ‘}’
THANKS

<do not remove the three backticks above>

Use Hash literal syntax - delete Hash.new, becase it doesn’t take block arguments.
Hash.new accepts a value which will be returned when trying to access non-existent key - default is nil.
Example:

    movies = Hash.new("nothing here")
    movies["somekey"]
    =>"nothing here"

Thanks for your help

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.