Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Know your closures: Ruby's blocks, procs, and lambdas (dev.gd)
5 points by biesnecker on Jan 6, 2013 | hide | past | favorite | 3 comments


``` If methods were first-class functions, this would work — > method_a would return method_b, which would then execute when x() was called. This doesn't work because Ruby methods aren't objects. ```

Seems the OP is just confused by syntax? we use obj.method(:method_a) instead of obj.method_a, i dont see why requiring a different syntax changes the semantics on this point.


This post deserved so many more upvotes! Fantastic summary, and explained lots of things I didn't quite get really well. Bookmarked.


In your example:

ampersandy(10) do |x| x + 10 end

# => 10

Actually the result should be '20' as well.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: