From: Xavier Noria Date: 2007-09-21T05:48:44+09:00 Subject: Re: Idiomatic Ruby for Array#extract / Range#length? On Sep 20, 2007, at 9:41 PM, Rick DeNatale wrote: > http://talklikeaduck.denhaven2.com/articles/2007/09/20/duck-a-la-range Well, the fact that the documentation says "must respond to" and "as long as" disallows in my view to pass objects that do not respond to #<=> and #succ. I think that is clear and unrelated to duck typing. Of course that may indicate that the documentation needs a different wording, but the current docs are clear and according to them if you pass an object that does not respond to #succ to the Range constructor the object is invalid, the code is invalid, albeit it may run. About rationals: I claim that the definition of a closed Range in Ruby (theoretically) allows for infinite ranges. That's my point. I prove that in ruby-talk giving an example. Now, the example uses the rationals because what I want to show follows easily from the fact that Q is bijectable with N, which is a basic result in set theory. (See proof in the mailing list.) Density is always relative to an ordering, and for brevity what I do is to change the order using a standard technique which consists of defining stuff into one set by transferring it from another through a bijection. The fact that the ordenary order of Q makes Q dense is not relevant to this discussion at all. You see a class with #<=> and #succ that provides an infinite Range. But that's just a way to support my claim, I could construct another thing and show it gives infinite Ranges (again, theoretically). I am sure I could simplify the proof for non-mathematicians taking N and Inifinity or something close to that. -- fxn