From: Martin DeMello Date: 2003-09-30T21:17:56+09:00 Subject: Re: Thoughts on yield Sabby and Tabby wrote: > > Possible. But not for long. > > #!/usr/bin/ruby -w > > def clef > yield > end > > def measure(m) > @lines = [] > yield > @lines.inject {|a,b| a.push(*b)} > end > > def chord > @lines[-1] = [yield] > end > > ('a'..'g').each {|x| eval <<""} > def #{x}(*a) > @lines << [] if a.empty? > @lines[-1].unshift('#{x}') > end > > notes = clef do > measure("4/4") do > c d e f g a b c > chord do > c e g > end > end > end > > p notes Beautiful. Pity it's going away. martin