From: Jeff Nyman Date: 2006-10-09T20:50:13+09:00 Subject: Re: Removing Duplicate Objects from Object List "gaspode" wrote in message news:1160393869.844030.8080@m7g2000cwm.googlegroups.com... > How are you storing the Rules in your RuleSet at the moment? Personally > I'd use an Array (or simply subclass Array) and then you get to use > Array.uniq without shifting objects back and forth. Essentially, I have a RuleList class like this: class RuleList def initialize @rules = Array.new end def append(this_rule) @rules.push(this_rule) end def selection @rules.find_all { |rule| rule } end end Then I have a Rule class like this: class Rule attr_accessor :point, :filter, :value def initialize(point, filter, value) @point = point @filter = filter @value = value end def to_s "#@point, #@filter, #@value" end end When a rule object needs to be added to the list, I do this: $ruleList.append(Rule.new(step.point2, rule, value)) Does that give enough detail? In playing around a bit more, I tried this: rules_array = $ruleList.selection.collect { |rule| rule } Then I tried: rules_array.uniq! The problem is that this finds nothing as a duplicate. But that makes sense (I think) because the object ID is probably being considered as part of the test and those will, of course, not be duplicates. It sounds like you're saying it would be better to not use a Rule class in the first place. Is that accurate? - Jeff