Explain the difference between send and public_send.

Last updated 27 June 2026

  • Both call a method dynamically by name, but send ignores visibility and can call private and protected methods.

  • public_send respects access control and raises NoMethodError for non-public methods, like a normal dot call.

  • Prefer public_send when dispatching on external input. Reserve send for deliberate internal access (tests, metaprogramming).

  • https://www.shivabhusal.com/2026/01/19/deduplication-of-string-objects-for-memory-efficiency-and-performance/
All Ruby interview questions