From: Dan Doel Date: 2003-12-01T18:31:46+09:00 Subject: Re: anything disappearing from Ruby for 2.0? Michael Campbell wrote: > That would work for the IO case, but I have used many times the ".." > as a flip-flop NOT relating to lines matching a regex. > > I think this is not the best thing for consideration of removal; I > haven't seen yet anyone get confused over it. This isn't nearly as concise as ".." notation, but: module Enumerable def range(from, to) inject(false) do |bool, val| bool ||= from === val yield val if bool bool &&= !(to === val) end end end [0,-1,34,8,9,0,1,2,3,4,5,6].range(-1,1) do |i| puts i end Which works for anything with #each. You could add an option for "..." behavior (if it's different. I can't remember). Isn't the problem with ".." that it's matching implicitly against Perl style variables? If you eliminate those, then ../... has to be replaced by either a message send to an object that can enumerate the values, or by a loop that handles things more explicitly. - Dan