On Fri, Mar 5, 2010 at 6:47 AM, Albert Schlef <albertschlef / gmail.com> wrote: > I have a function that generates some textual data that I capture into a > string: > > ¨Âåæ çåîßäáôá¨ïõôðõô¬ ®®®© > .. > ¨Âõôðõ¼¼ ¢®®® óïíå äáôá ®®®¢ > .. > ¨Âîä > > ¨Â §§ > ¨Âåîßäáôá¨ó¬ ®®®© I'd just have gen_data return the string and let the caller make the append to the string. What you have looks like an output argument and that's what the return value of the method should be used for, if possible: def gen_data ... output = "...some data..." ... output end s = "" s << gen_data I suppose there's a way to redirect where puts writes into a String as Robert has shown, but that could have some problems, as you stated: if some other code inside uses puts, it will get appended to the string. So, if that is exactly your use case (redirect all stdout to a string for a method call) that could work. But I'd refactor the method, if all you want to do is to return a string to the caller. Jesus.