Skip to content

Instantly share code, notes, and snippets.

@variousauthors
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save variousauthors/10999437 to your computer and use it in GitHub Desktop.

Select an option

Save variousauthors/10999437 to your computer and use it in GitHub Desktop.
Rockets Rockets Rockets

I'm not down with the new(er) Ruby hash syntax. I'm not down.

In javascript, I can do this:

hash = {
  first  : "one"
  second : "two"
  third  : "three"
}

In Ruby, I can do this,

hash = {
  rocky:    "one"
  mountain: "two"
  roads:    "three"
}

or I can do this:

hash = {
  :smooth  => "one"
  :vanilla => "two"
  :days    => "three"
}

The advantages of the second method are fairly clear. Smooth vanilla days.

The hash rocket syntax isn't deprecated, as detailed in this SO answer, and I don't think the new(er) syntax is "nicer" in the case of defining hashes (it is totally great for named params, though). We can use both, and I intend to use both. I know Michael will still make fun of me, but I feel pretty OK with this.

@nomoon

nomoon commented Apr 18, 2014

Copy link
Copy Markdown

What about

hash = {
  rocky:    "one"
  mountain: "two"
  roads:    "three"
}

@variousauthors

Copy link
Copy Markdown
Author

Still! What I'm saying is, when I use :tab /: in Javascript, I get nicely columnized hash definitions. If I use the same command in Ruby, I get a syntax error. I totally prefer hash rockets for hash definitions. (I have corrected my examples above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment