Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Method#[]
(?) -> untyped
self[...] → obj
proc.c
View on GitHub ↗
static VALUE
rb_method_call_pass_called_kw(int argc, const VALUE *argv, VALUE method)
{
return rb_method_call_kw(argc, argv, method, RB_PASS_CALLED_KEYWORDS);
}
Alias of #call
Invokes self 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