Bradley Harris

Lesson Learned - What Is the Difference Between a Block, a Proc, and a Lambda in Ruby?

As a software developer who works remotely, I spend a lot of time on the internet. I read a lot and I learn a little. Sometimes I learn bits of trivia and minutia, less often I learn useful tips for work and life, rarely I learn big profound lessons.

I am making it a goal to collect something I learn everyday and write about it.

Today’s lesson:

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

This one came up in my RSS reader and I nearly breezed past after reading the title. I have done a fair amount of working with all three of those constructs in Ruby. As I scrolled on I thought to myself, “That is easy. The difference is…” I remembered examples of times that I worked with each of them and times when I had to manage the differences and convert between them. In programming there are tons of examples of things like this that you have encountered, worked through, and often partially mastered. Yet when the question is asked directly you realize that you don’t really “know.” When I recognized that I was in such a situation I stopped and scrolled back. The link has a great explanation that I won’t attempt to expand or re-create. The more important lesson for me was to be on the lookout for things you think you know and don’t miss out on the little chances to improve and solidify that knowledge.