From: Dave Thomas Date: 2001-10-10T10:31:17+09:00 Subject: [ruby-talk:22367] Re: blocks with min and max matz@ruby-lang.org (Yukihiro Matsumoto) writes: > |If a collection has specific collation rules, then keeping it with > the |collection might be more encapsulated that spreading through > the code |that uses the collection. That's all I was thinking. > > Hmm, trade off. How about using singleton method? > > def ary.<=>(a,b) > ... > end > > This requires no enhancement. I went down that route too, but isn't the comparison between the _elements_, not the collection? So ary.max would need <=> defined for each element in ary, which _seriously_ breaks encapsulation :) I still like the idea of being able to specify the comparison method as part of Enumerable or Comparable's interface. Dave