On Thu, 19 Jul 2001, Dave Thomas wrote: > The use of NIL to save a variable here is a bit tacky... > > def NIL.n=(n)@n=n;end;def NIL.to_s() %[#@n bottle#{@n==1?"":"s"} of beer];end > 99.downto(1){|NIL.n|print "#{NIL} on the wall, #{NIL}.\n"; > puts "Take one down, pass it around,"};puts "No more bottles of beer on the wall." > > Or, slightly tider... > > > def NIL.n=(n) @n = n; end > def NIL.to_s() %[#@n bottle#{@n == 1 ? "" : "s"} of beer]; end > > 99.downto(1) { |NIL.n| > print "#{NIL} on the wall, #{NIL}.\n" > puts "Take one down, pass it around," > } > puts "No more bottles of beer on the wall." The only thing is, it sings a slightly revisionist version of the song: [...] Take one down, pass it around, 8 bottles of beer on the wall, 8 bottles of beer. Take one down, pass it around, 7 bottles of beer on the wall, 7 bottles of beer. as opposed to: [...] Take one down, pass it around, 8 bottles of beer on the wall. 8 bottles of beer on the wall, 8 bottles of beer. Take one down, pass it around, 7 bottles of beer on the wall. 7 bottles of beer on the wall, 7 bottles of beer. British version, perhaps? :-) OK, now I'm unabashedly going for minimalism: b=Hash.new("bottles of beer") b[1]=b[2].tr's','' w="on the wall" p="Take one down, pass it around," 99.downto(1){|c|n="#{c} "+b[c] puts n+" "+w+"."+"\n"if c<99 puts n+" "+w+", "+n+"."+"\n"+p} puts "No more "+b[2]+" "+w+"." David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav