From: Michel Demazure Date: 2010-12-31T19:50:37+09:00 Subject: Re: a common idiom Michael Fellinger wrote in post #971622: > compact Yes ! I knew there was a method, but forgot the name, browsed thru Flanagan-Matz, and did not find it. > results = [] > some.each do |value| > results << value.operation if value.condition? > end Yes, returning results, but I try to avoid this extra variable. I dislike (question of taste) the pattern def ... res = [] ... res << ... res end Another way is using tap Array.new.tap do |res| ... end A bit snob, no ? -- Posted via http://www.ruby-forum.com/.