From: Peter Versteegen Date: 2007-08-23T21:06:28+09:00 Subject: Re: Pretty Printing Douglas, Thanks, this works also. The result is put in a string and the string is printed. I guess what I was trying to do is to create a string that ruby is supposed to interpret, or execute. Perhaps there is another command to accomplish this. Peter On Aug 22, 2007, at 8:07 AM, Douglas F Shearer wrote: > Hi Peter. > > On 22 Aug 2007, at 12:21, Peter Versteegen wrote: >> # But this approach doesn't. Why not? Are there other ways to >> make this simpler? > > Maybe I've got the wrong end of the stick on this, but I get it to > work like this: > > ========================== > > a = ["a-value","b-value", "c-value"] > b = [10,30,15] > > def header(names, widths) > header = '' > names.each_with_index do |v,i| > header += v.rjust widths[i] > end > header > end > > p header(a, b) > > ========================== > > Hope this helps. > > Douglas F Shearer > dougal.s@gmail.com > http://douglasfshearer.com > > >