From: Noah Easterly Date: 2007-08-08T03:40:06+09:00 Subject: Re: array.each puzzle from new ruby-er On Aug 7, 2:04 pm, Gani Ruthellen wrote: > > Know that this is actually rebinding the local variable y to point to a > > new object, not modifying the old object. If your goal was to modify the > > array "lines", you should change "lines.each" to "lines.map" and make > > sure you end the block with a statement that returns the modified y. > > > perhaps: > > lines.map do |y| > > y = y.chomp("\x15").chomp > > y = "" + y + "" if y =~ /^\*\*\*/ > > y > > end > > > Dan > > Sorry, actually doing each_with_index do |y,ind| (etc) and specifically > setting lines[ind] = y > but my original question remains: how do i make the "" + y leave > off the \n so the output is > text of y > Thanks again > -- > Posted viahttp://www.ruby-forum.com/. Have you considered switching to map? As for debugging, I'd try tracking it down using p lines = file.readlines("\x15").map do |line| line.chomp!("\x15") line.sub!(/^\n/, "") line = "" + line + "" if line =~ /^\*{3}/ p [:line, line] # comment me out after debugging line end p [:lines, lines] # comment me out after debugging puts lines