使用send传递参数

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

 

等价于

 

k.hello("gentle", "readers")

 

你可能感兴趣的:(send)