From: Robert Klemme Date: 2007-10-31T21:03:48+09:00 Subject: Re: Code to DRY 2007/10/31, Michel Demazure : > 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". Ah, I see. I wasn't aware of this. In that case it's probably also not a good idea to use <, > etc. to avoid confusion. Do you use some kind of topological sort then? > 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! I still do not know how you use min and max but it certainly sounds interesting! :-) Kind regards robert -- use.inject do |as, often| as.you_can - without end