Skip to content

Instantly share code, notes, and snippets.

@rebx
Created April 18, 2013 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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