Hi,
In message "Re: chaining comparisons"
on 03/07/19, news_chr <swap / gmx.net> 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.