Explain the difference between a block and a Proc.

Last updated 27 June 2026

A block is an anonymous chunk of code passed to a method; it is not an object on its own. A Proc is a block wrapped in an object that you can store in a variable, pass around, and call multiple times.

  • A block is syntax, not a value: Written with do...end or { }, a method may receive only one block, invoked with yield or a &block parameter.

  • A Proc is a first-class object: Created with Proc.new, proc { }, or lambda; stored, passed, and called with .call.

  • Conversion between them: Prefixing a parameter with & turns a passed block into a Proc inside the method, and & on a Proc turns it back into a block at the call site.

  • Two flavors of Proc: Lambdas check argument count strictly and return only from themselves; non-lambda procs are lenient and return from the enclosing method.

  • https://www.reddit.com/r/rails/comments/1shfrbq/3_years_rails_dev_but_failed_basic_interview/
All Ruby interview questions