[Ruby] define singleton method with default value
define_singleton_method :foo do |params = {}|
params
end
foo
# => {}
foo(bar: :baz)
# => { bar: baz }
Written by Rafael Felix
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#