Question

Working on dictionary lesson from Test First Teaching

In my dictionary.rb file I've got

def add(hash)
  @new = Hash[hash]
  @entries.merge!(@new)
end 

My spec file uses add like this: @d.add('fish' => 'aquatic animal') Which works.

However, when I'm in pry if i set: a = 'monkeys' => '3' I get SyntaxError: unexpected =>, expecting end-of-input a = 'monkeys' => '3'

What gives?

Was it helpful?

Solution

You cannot omit the braces {} of a hash literal in that environment. Where you can do it is within arguments, arrays, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top