From: "Stephan Kämper" Date: 2001-12-16T07:14:35+09:00 Subject: [ruby-talk:28648] Re: Reviews solicited for Ruby article Bill Kelly wrote: > > From: "Bill Kelly" > > > counts = Hash.new(0) > > text.scan(/[A-Z]/).each {|c| counts[c] += 1} > > By the way, I realized last night the 'each' is not even necessary, > as - ofcourse ! - one can pass a block straight into scan: > > text.scan(/[A-Z]/) {|c| counts[c] += 1} > Wow, I had some objections against the upper solution: Seems that I can't parse more than two chained messages well mentally. That 'each.'less version was immediately clear to me. > Does Ruby Rock, or what !?? :-) > Yep! Happy Rubying, Stephan