What Is the Difference Between a Block, a Proc, and a Lambda in Ruby? (2013)

blog.awaxman.com

86 points by Tomte a year ago


maxlapdev - 10 months ago

For those unaware, Ruby blocks (and procs) are more flexible than anonymous functions as most language implement them. The article briefly goes over that, mentioning that lambda (regular anonymous functions) and procs (blocks) don't treat execute `return` the same way. There are also particularities with regard to next (continue) and break.

I made a post about the niceties of blocks: https://maxlap.dev/blog/2022/02/10/what-makes-ruby-blocks-gr...