-6

What is the difference between these examples?

a = {'a' : 'b'}
a = {'a' => 'b'}
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
bryantism
  • 167
  • 9
  • 2
    It is not a duplicate of the question that it was claimed to be of. The first form is simply a syntax error. – sawa Jun 15 '16 at 14:33

1 Answers1

3

The first one is wrong, and gives you a syntax error. With the second syntax, you can use a key of any class. Otherwise, this syntax is just a shortcut for a symbol key.

a = {a: 'b'}

is equivalent to:

a = {:a => 'b'}
sawa
  • 165,429
  • 45
  • 277
  • 381
Ursus
  • 29,643
  • 3
  • 33
  • 50