Explain the difference between send and public_send.
Last updated
Both call a method dynamically by name, but send ignores visibility and can call private and protected methods.
public_sendrespects access control and raisesNoMethodErrorfor non-public methods, like a normal dot call.Prefer
public_sendwhen dispatching on external input. Reservesendfor deliberate internal access (tests, metaprogramming).