From: Stefano Crocco Date: 2007-10-15T05:36:26+09:00 Subject: Re: Nested blocks? Alle domenica 14 ottobre 2007, Randy Kramer ha scritto: > 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. File.open("test.aml", "w") do |f| File.foreach("test.txt"){|l| f.write l} end I hope this helps Stefano