MΓ³dulo 25 Β· Blocks, Procs & Lambdas β LecciΓ³n 3 de 6 Β· ~11 min
Lambdas vs Procs
A lambda IS a proc β with two strict differences
->(x) { x * 2 } creates a lambda, which is a Proc object (lambda.class == Proc, lambda.lambda? == true). But it behaves more strictly than a plain proc in exactly two ways, and those two differences are a top-5 Ruby interview question.
In an interview, say: "A lambda is a proc with method-like semantics: it checks arity strictly, and
returninside it returns from the lambda, not from the enclosing method. Plain procs are lenient on arity and theirreturnblows through the enclosing method."