From: Michael Boutros Date: 2007-12-12T10:49:31+09:00 Subject: Re: How To Avoid Ugly Declerations Suraj Kurapati wrote: > Michael Boutros wrote: >> 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? > > def some_method foo > foo.map {|f| f.reverse} > end Thanks for that, I'll be using that more often now :) However, I'm having trouble refactoring this code into something like yours... def get_text(*elements) results = [] elements.each {|element| results << self.search(element).first} return results end -- Posted via http://www.ruby-forum.com/.