From: Robert Klemme Date: 2004-02-01T21:29:50+09:00 Subject: Re: Save the flip/flop op! "Hal Fulton" schrieb im Newsbeitrag news:401C0A45.3000504@hypermetrics.com... > Phil Tomson wrote: > >>That's why I personally would like to see it gone, and good riddance. > >>You, of course, are welcome to root for a pardon, but I just wanted to > >>make sure the other side of the aisle was represented :-) > >> > > And just what would you replace that functionality with? > > Phil, > > I'm with Nathaniel. Save the functionality but please KILL the > syntax. Only a perler could love it. (No offense meant.) > > I haven't thought this through yet. But let's do it with a > method call. > > #untested > f.set_context(/BEGIN/,/END/) > f.each_line do |l| > if f.in_context > # do something with l... > else > # whatever > end > end > > > Comments, Phil? Nathaniel? Others? I wouldn't put it into File or IO since this is too specialized functionality. It deserves a class of it's own: class FlipFlop def initialize(on, off) @on, @off = on, off @state = false end def ===(o) if @state @state = false if @off === o else @state = true if @on === o end @state end end io=<