Skip to content

Instantly share code, notes, and snippets.

@rebx
Created April 18, 2013 22:59
Show Gist options
  • Save rebx/5416895 to your computer and use it in GitHub Desktop.
Save rebx/5416895 to your computer and use it in GitHub Desktop.
Some Ruby Idioms I have come across which are useful to me
# make a list into hash keys
list = %w{foo bar baz}
s ||= {}
list.each {|key| s[key.to_sym] = 1}
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment