method

send

v1_9_3_392 - Show latest stable - Class: Object
send(*args)
public

Invokes the method identified by symbol, passing it any arguments specified. You can use __send__ if the name send clashes with an existing method in obj.

class Klass
  def hello(*args)
    "Hello " + args.join(' ')
  end
end
k = Klass.new
k.send :hello, "gentle", "readers"   #=> "Hello gentle readers"

1Note

Alternative to :symbol

ibnukamy ยท Feb 4, 2014

You can also pass string as an alternative to :symbol

k = Klass.new

k.send "hello", "gentle", "readers" #=> "Hello gentle readers"