Hi -- On Wed, 21 Jul 2010, Vitaliy Yanchuk wrote: > Rob Biedenharn wrote: >> Soo... that has a semi-colon and isn't then a one-liner?? ;-) > > Yeah, not perfectly one-liner. But it is without dot-chain breaking, not > bad too :) In Ruby 1.9 there's Enumerator#with_object, which is a nice way to avoid that "; h" thing that you have to do in #inject to make it return the accumulator: count_hash = a.each.with_object(Hash.new(0)) {|e, hash| hash[e] += 1 } David -- David A. Black, Senior Developer, Cyrus Innovation Inc. The Ruby training with Black/Brown/McAnally Compleat Philadelphia, PA, October 1-2, 2010 Rubyist http://www.compleatrubyist.com