Hi,
I found this very helpful:
http://innig.net/software/ruby/closures-in-ruby
As the name suggests it is mainly about closures but still.
Best regards
Attila
···
On Sat, Apr 13, 2013 at 1:42 AM, Alex Chaffee <alex@stinky.com> wrote:
Blocks - Code Like This has slides and a
video lecture that might help you out.Basically, yield is calling an anonymous, invisible function pointer.
It's sort of likedef foo(p)
p.call("Jim")
enddef bar
baz = lambda { |n| n.upcase }
foo(baz)
endThe & turns a proc into a block and back again.
It's one of the oddest parts of Ruby and it's almost (but not
entirely) syntactic sugar so you can use "do" blocks to make your code
look cool. (Not a dis: I think it's great, but it is confusing.)- A