Why doesnt this work?


If i create the hash like this, the program doesn't behave correctly:
(i can add an already existing title and so on)

movies = {
    'Jedi' => 4,
    'Turtles' => 3,
    'Klowns' => 4

if i do it like this the program behaves correctly

movies = {
    Jedi: 4,
    Turtles: 3,
    Klowns: 4

What am i missing here?



We will need a little more infomation to work with:

  • a link to the exercise
  • the error message returned by the SCT
  • any console error message returned by the interpreter


Its the new update, they changed it, second one you have to use instead of rocket.


Then how is one supposed to write, "Motorcycle Diaries"? The second way does not work.


hash = {
key: value
another: value2

instead of

hash = {
"key" => "value"
"another" => "value2"


Keys that are single term, meaning no white space, may be unquoted. They are the symbol that repesents the association. value if unquoted needs to be already defined, and if it is an array or a hash (or a method) will be a reference only to to that object. This is a Nota Bena.

The associated value may be any object. If it is not already defined, then this assigment must be literal. Spell out the object in accorded syntax. It the object is a string, then quote it. A number needs no definition. It is what it is, as with booleans and nil.

When keys are single terms, unquoted they may be written as symbols, directly...

key: "value",

When they contain white space, they must be quoted...

"my key" => "value",

And now the 'rocket' emerges. Quoted strings can not be written as symbols. We must represent them as symbols.