Ruby Block and Closure

January 8, 2008

The most difficult part of Ruby Language for any ruby new comer is block and closure. Those two features are not very common among other modern high level programming languages like PHP or Java. They are used extensively in ruby magics. Here is what I found useful while learning.First, I went through “Chapter 4 Containers, Blocks and Iterators” from book Programming Ruby 2nd Edition, here the first edition free online. I highly recommend you get this book. The 2nd edition covers ruby 1.8, at this time Ruby has released version 1.9. For changes in Ruby 1.9 check out this great blog post at Eigenclass.To help you understand Closure better, here is more examples. More tutorials from DevArticles – Ruby Blocks and Iteration and Ruby Learning . Also, here is an interview with Yukihiro Matsumoto the creator of Ruby about blocks and closures. He talked about the importance of blocks and what makes block a closure. He also noted what is the benefit of real closure and where he got inspiration from

—-
update 2008-01-14

InfoQ: The state of the Lambda in Ruby 1.9 talked about Ruby Closure and Block in general, also what’s new in Ruby 1.9 for block and closure. 

Leave a Reply