Skip to content
instance method

Method#call

(?) -> untyped
meth.call(args, ...) → obj

Invokes the meth with the specified arguments, returning the method’s return value.

Example
m = 12.method("+")
m.call(3)    #=> 15
m.call(20)   #=> 32

Using Method#=== allows a method object to be the target of a when clause in a case statement.

Example
require 'prime'

case 1373
when Prime.method(:prime?)
  # ...
end
See also #box #clone #arity #curry also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0