From: Xavier Noria Date: 2007-11-19T10:23:05+09:00 Subject: Re: Open-ended ranges? On Nov 19, 2007, at 1:50 AM, Clifford Heath wrote: > What I really want is to be able to define ranges like (1..nil), > which is an > open-ended range starting from 1. Of course this doesn't work, but > not for the > reason I expected. There seems to be some magic inside MRI that > prevents it. > > Like if I define: > > class End > attr_reader :e > def initialize(e) > @e = e > end > def <=>(other) > @e <=> other.e > end > def succ > @e && @e.succ > end Note that #succ is expected to return an instance of End. In particular End.new(nil).succ should return some End instance. I'd expect as well x < x.succ for all x in End and if you add that condition you end up putting something at the end of the positive integers, and adding its successors. As if you put a copy of N after N. That's one of the examples we talked about some weeks ago: http://advogato.org/person/fxn/diary/473.html -- fxn