Brian Candler wrote: > > I don't really see the need to define a 'function' again from > scratch, when you have lambda {...} natively. Pascal was making a simulation of first-class functions in ruby. The difference between lambda { } and a real first-class function is quite profound. When I say that I prefer functional style in ruby, I mean that this def sum(array) array.inject(0) { |acc, x| acc + x } end is better than this def sum(array) result = 0 for x in array result += x end result end In addition, chaining blocks/lambdas can often be terser/better than the imperative equivalent. When the details of the step-by-step operations are abstracted, the result is smaller code with less room for error. I use functional-ness in ruby on a small scale, such as inside the implementation of a method, but no wider. For reasons I gave earlier, functional style is most applicable to flat arrays and hashes, and probably less so with more complex structures (http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/472e714cffa0f50c). -- Posted via http://www.ruby-forum.com/.