Skip to content

Instantly share code, notes, and snippets.

@karloku
Created March 30, 2016 11:54
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 karloku/30f6d7f98d99a67b1260ea057f16d5db to your computer and use it in GitHub Desktop.
Save karloku/30f6d7f98d99a67b1260ea057f16d5db to your computer and use it in GitHub Desktop.
Using ES6 style {a, b, c} hash construct in Ruby ref: http://qiita.com/karloku/items/0a3c8ed3e39518de5b90
var year = 2016;
var month = 3;
var day = 30;
var theDate = { year, month, day };
def HandyHash(&list_block)
variables = yield.map(&:to_s)
Hash[
variables.map do |variable|
[variable.to_sym, list_block.binding.local_variable_get(variable)]
end
]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment