When would you use a Proc instead of a block?
Last updated
Use a
Procwhen 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
lambdafor strict arity checking and a localreturn. A plain block suffices for one-off code passed to a single method.