3 ms·
Yes, the author seems to be referring to higher-order functions as "closures". > Listing 1. The simplest possible closure > 3.times {puts "Inside the times me
by jberryman 15y ago
Yes, the author seems to be referring to higher-order functions as "closures".
> Listing 1. The simplest possible closure
> 3.times {puts "Inside the times method."}
that's not the simplest possible anything. it's magical syntactic sugar gone wild.
- evincarofautumn 15y agoNot really “magical syntactic sugar gone wild”, just “everything is an object”. In Ruby, integers can respond to messages just as well as anything else, and the built-in “times” message takes a lambda (“closure” in the article). There is some small irony in that “times” is just a very thin wrapper for a “for” loop.