From: Daniel Berger Date: 2005-04-14T06:11:08+09:00 Subject: Re: Weaving Arrays galizur@gmail.com wrote: > Any suggestions on a quick way to weave two arrays? > > To split up a file with fixed width columns, and to then insert > a tab after each one, is fast and easy: > > File.open($*[0]).each do |raw_line| > line = raw_line.chomp.unpack($format) > last = line.pop > $stdout << line*"\t" << last << "\n" > end > > But what if I wanted to do something more general, such as weaving > two arrays? Perhaps Enumerable#inject or Enumerable#zip are what you're looking for. Otherwise, you'll have to whip up a manual solution I think. Regards, Dan