From: Brian Candler Date: 2004-10-05T20:26:56+09:00 Subject: Re: [RCR] New [] Semantics On Tue, Oct 05, 2004 at 07:38:01PM +0900, trans. (T. Onoma) wrote: > > Besides, > > a = a.succ > > and > > a = a + 1 > > take almost identical amounts of time, since even '+ 1' involves a method > > dispatch: > > a = a.send(:+,1) > > With inc/dec modulo can be used. Something like: > > def member?(e) > return ( (((e + self.begin) % @increment) == 0) && self.between?(e) ) > end Erm, no I don't get that. You're declaring a 'member?' test for a class of objects which support the methods '+', '%', 'between?' and '==' with some particular semantics (they form a group?? IANAM), but presumably not numbers. Can you give an example of a class of objects for which your 'member?' function is useful, but this one is not: def member?(e) return e >= self.begin and e <= self.end end #or def member?(e) return e.between(self.begin, self.end) end I also can't see what "x.between?(y)" is supposed to do, with a single argument (y). Regards, Brian.