From: matz@... (Yukihiro Matsumoto) Date: 2003-07-19T20:48:01+09:00 Subject: Re: chaining comparisons Hi, In message "Re: chaining comparisons" on 03/07/19, news_chr writes: |class Fixnum | alias __lt < | alias __le <= | alias __gt > | alias __ge >= | def <(r) | __lt(r) ? r : nil | end | def <(r) | __lt(r) ? r : nil | end | def <=(r) | __le(r) ? r : nil | end | def >(r) | __gt(r) ? r : nil | end | def >=(r) | __ge(r) ? r : nil | end |end | | |class NilClass | def <(r) self end | def <=(r) self end | def >(r) self end | def >=(r) self end |end | | |p ((4 < 5) < 6) < 7 # 7 | |p ((4 < 5) < 5) < 7 # nil | |p ((4 < 5) >= 5) < 7 # 7 |---- | |Personally I wouldn't mind such a semantic but it is |probably too wired for general consumption ... They used to work like this long time ago. But I felt the semantic was too weird. matz.