From: Justin Collins Date: 2007-12-12T09:26:36+09:00 Subject: Re: How To Avoid Ugly Declerations Michael Boutros wrote: > Hello! More and more I find myself having to do something like this: > > def some_method(foo) > results = [] > foo.each {|f| results << f.reverse} > return results > end > > As you can see, that is some pretty ugly code, but it's also a common > scenario. How can I make it a little less ugly? > > Thanks, > Michael Boutros > In this specific case... def some_method(foo) foo.map { |f| f.reverse } end Use methods which return new objects and take advantage of implicit return values. -Justin