[Tfug] Language choices
Tim Ottinger
tottinge at gmail.com
Thu Nov 9 21:07:38 MST 2006
I found a good discussion of blocks and closures at
http://www.artima.com/intv/closures.html
There's a use for memoizing here:
http://www.braithwaite-lee.com/tips/closures.html
thrice_with_local in an example in
http://innig.net/software/ruby/closures-in-ruby.rb
as does:
def save_for_later(&b)
@saved = b # Note: no ampersand! This turns a block into a
closure of sorts.
end
save_for_later { puts "Hello!" } # <----<<<< Look here! Just like
"synchronized"!!
puts "Deferred execution of a block:"
@saved.call
@saved.call
More information about the tfug
mailing list