tags:

views:

50

answers:

3

In a book they showed me this declaration:

friends = [ { first_name: "Emily", last_name: "Laskin" }, { first_name: "Nick", last_name: "Mauro" }, { first_name: "Mark", last_name: "Maxwell" } ]

This doesn't look like a hash. And when I enter it in IRB i get an error.

What is this format?

+4  A: 

The {key: value} syntax is new in 1.9 and is equivalent to {:key => value}.

sepp2k
+4  A: 

It is an array of hashes, only the hashes are 1.9 style hashes.

Adrian
+5  A: 

It's an array of hashes, written in the Ruby 1.9 hash syntax.

{ first_name: "Emily", last_name: "Laskin" }

is equivalent to:

{ :first_name => "Emily", :last_name => "Laskin" }
Chuck