Created
November 30, 2016 20:05
-
-
Save eam/aeebb0b2f17805fe2259dba8f292d7fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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