Randy Kramer wrote:
> The following works fine but I had some thoughts about trying to convert it to 
> two nested blocks (because of the extra goodness of blocks).
> 
> Can anybody tell me how to do that?  I've been looking at the relevant pages 
> of the pickaxe (version 2) (around pages 49 thru 55), but that hasn't helped 
> me so far. ;-)
> 
> Is it worth doing?
> 
> g = File.open("test.aml", "w")
>    File.open("test.txt", "r").each { |line| g.puts line}
> g.close
> 
> Randy Kramer
> 
> Aside: I suppose it's obvious, but basically the program copies test.txt to 
> test.aml one line at a time.
> 

I haven't tested this but I think it'll do the trick. Hmmm...this is 
three nested blocks.

File.open("test.aml", "r") do |input|
	File.open("test.txt", "w") do |output|
		input.each {|line| output.puts line }
	end
end


-- 
RMagick OS X Installer [http://rubyforge.org/projects/rmagick/]
RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?forum_id=1618]
RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html]