From the Doc of define_singleton_method
I got two syntax to define the singleton
method as below :
define_singleton_method(symbol) { block } -> proc :
With the above syntax I tried the below code and the syntax I understood:
define_singleton_method :foo do |params = {}|
params
end
#=> #<Proc:0x20e6b48@(irb):1 (lambda)>
foo
#=> {}
foo(bar: :baz)
#=> {:bar=>:baz}
foo(bar: :baz ,rar: :gaz )
#=> {:bar=>:baz, :rar=>:gaz}
But need someone's help to figure out one example of each with the below syntax.
define_singleton_method(symbol, method) -> new_method
as per the doc - The method parameter can be a Proc
, a Method
or an UnboundMethod
object. I didn't get any examples there.
Can anyone help me here to get one example of against the italic words?