Skip to content
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

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"