wow - you learn something every day - that's great!
cheers.
-a
···
On Thu, 16 Nov 2006, Robert Klemme wrote:
Small correction: if called *without arguments* the first invocation will look like this:
>enumerable_element_1, enumerable_element_2|
%w{foo bar baz}.inject {|*a| p a}
["foo", "bar"]
[nil, "baz"]
=> nil%w{foo bar baz}.inject(nil) {|*a| p a}
[nil, "foo"]
[nil, "bar"]
[nil, "baz"]
=> nilThis is actually useful to do something like this:
%w{foo bar baz}.inject() {|a,b| a+", "+b}
=> "foo, bar, baz"
--
my religion is very simple. my religion is kindness. -- the dalai lama