Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Object#public_send

obj.public_send(symbol [, args...]) → obj
obj.public_send(string [, args...]) → obj

Invokes the method identified by symbol, passing it any arguments specified. Unlike send, public_send calls public methods only. When the method is identified by a string, the string is converted to a symbol.

Example
1.public_send(:puts, "hello")  # causes NoMethodError