Skip to content

Instantly share code, notes, and snippets.

@eam
Created November 30, 2016 20:05
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 eam/aeebb0b2f17805fe2259dba8f292d7fc to your computer and use it in GitHub Desktop.
Save eam/aeebb0b2f17805fe2259dba8f292d7fc to your computer and use it in GitHub Desktop.
def fun(thing, option: true, other_option: false)
method(__method__).parameters.select {|e| e.first == :key}.map {|e| instance_variable_set "@"+e.last.to_s, binding.local_variable_get(e.last)}
puts "now you have ivar @option: #{@option} and @other_option: #{@other_option}"
end
fun(5, option: 6, other_option: 7)
##### now you have ivar @option: 6 and @other_option: 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment