When would you use a Proc instead of a block?

Last updated 27 June 2026

  • Use a Proc when behavior must be treated as data: passing several callables (a method takes only one block) or reusing the same logic across calls.

  • Use one to store a callback (e.g. in an instance variable) and run it later with .call.

  • Choose a lambda for strict arity checking and a local return. A plain block suffices for one-off code passed to a single method.

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