instance method
BasicObject#__send__
(::interned name, *untyped, **untyped) ?{ (?) -> untyped } -> untyped
foo.send(symbol [, args...]) → obj
foo.__send__(symbol [, args...]) → obj
foo.send(string [, args...]) → obj
foo.__send__(string [, args...]) → obj
vm_eval.c
View on GitHub ↗
VALUE
rb_f_send(int argc, VALUE *argv, VALUE recv)
{
return send_internal_kw(argc, argv, recv, CALL_FCALL);
}
Invokes the method identified by symbol, passing it any arguments specified. When the method is identified by a string, the string is converted to a symbol.
BasicObject implements __send__, Kernel implements send. __send__ is safer than send when obj has the same method name like Socket. See also public_send.
Example
class Klass def hello(*args) "Hello " + args.join(' ') end end k = Klass.new k.send :hello, "gentle", "readers" #=> "Hello gentle readers"
See also
#method_missing
#singleton_method_added
#instance_exec
#singleton_method_removed
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0