From: Michel Demazure Date: 2007-10-31T19:56:29+09:00 Subject: Re: Code to DRY Robert Klemme wrote: > 2007/10/31, Michel Demazure : >> >> end >> >> end >> > >> > And instead of #le?, why not #<, #==, #>, #<=>? >> >> #< looks good. Thanks. > > Also keep attention to module Comparable > http://www.ruby-doc.org/core/classes/Comparable.html > > Basically you need to only implement <=> and get all other operators for > free. > > Btw, what do you need min and max for? > > Kind regards > > robert Robert, Actually, I have partial orders ("pr辿ordre" in french) and not orders ("ordre total" in french), so <=> does not work well. For instance, you can have a.le?(b) and b.le?(a), but not a = b. Or neither a.le?(b), nor b.le?(a). For instance a.lt?(b) is "a.le?(b) and not b.le?(a)" but not "a.le?(B) and a != b". I need min and max for semantic reasons, analogous to Scott's semantics for programming languages : 'min' is something like 'undefined' (definitely less than 'defined with value nil' for instance) and 'max' is something like 'overdefined' or 'impossible'. All this for some try at a "fuzzy knowledge" management program...which actually works quite well! Best, Michel -- Posted via http://www.ruby-forum.com/.