From: John Joyce Date: 2007-04-29T10:12:28+09:00 Subject: Re: Output A File w/ Line Numbers? On Apr 29, 2007, at 9:47 AM, James Edward Gray II wrote: > On Apr 28, 2007, at 7:11 PM, John Joyce wrote: > >> >> On Apr 29, 2007, at 4:49 AM, James Edward Gray II wrote: >> >>> See the standard generator library for doing this without a counter. >> You just made up that name right? > > Nope: > > >> require "generator" > => true > >> enum = %w[one two three] > => ["one", "two", "three"] > >> gen = Generator.new(enum) > => # 0x14be050>, cont_nextnil, queue["one"], block# local/lib/ruby/1.8/generator.rb:71>, index0 > >> gen.next? > => true > >> gen.next > => "one" > >> gen.next? > => true > >> gen.next > => "two" > >> gen.next? > => true > >> gen.next > => "three" > >> gen.next? > => false > > James Edward Gray II > Sure enough it's in the Ruby Standard LIbrary, among the things the pickaxe glances over at the end.... I'll have to dig through that. Very interesting, but could lean towards more C++/Java-ish looking code perhaps. Nonetheless, 1000 thanks to all.