From: Rick DeNatale Date: 2007-09-21T04:41:15+09:00 Subject: Re: Idiomatic Ruby for Array#extract / Range#length? On 9/20/07, Xavier Noria wrote: > On Sep 20, 2007, at 7:26 PM, Rick DeNatale wrote: > > > Getting back to the original thread though, it's actually not quite > > true that ranges require the starting and ending elements to implement > > succ, > > Ah, I thought they did because of this excerpt from the Pickaxe: > > "So far we've shown ranges of numbers and strings. However, as you'd > expect from > an object-oriented language, Ruby can create ranges based on objects > that you define. > The only constraints are that the objects must respond to succ by > returning the next > object in sequence and the objects must be comparable using <=>." > > Also, the documentation of Range says: > > "Ranges can be constructed using objects of any type, as long as the > objects can be compared using their +<=>+ operator and they support > the +succ+ method to return the next object in sequence." > > So, in what sense succ is not required? http://talklikeaduck.denhaven2.com/articles/2007/09/20/duck-a-la-range -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/