From: "Brian Schröder" Date: 2004-12-09T23:45:37+09:00 Subject: Re: binding question On Thu, 9 Dec 2004 22:52:28 +0900 Florian Gross wrote: > Brian Schr�der wrote: > > > labels = %w[one two three four five].inject({}) { | result, name | > > result[name] = TkLabel.new(:text => name, :bg => 'white') do > > pack(:side => :top) > > end > > result > > } > > I'm always a bit skeptic about using .inject with in-place operations -- > it seems to defy its purpose. Sure, it makes code a bit shorter, but is > it really worth that? I'm not certain. > Thats obviously a matter of taste. I like this code, because I'm injecting a seed and a lambda into the array thereby transforming it into something else. To me that is what inject is all about. I don't see a fundamental difference between the above and (0..10).inject(0) { | r, v | r + v } best regards, Brian -- Brian Schr�der http://www.brian-schroeder.de/