特定の条件の場合にオブジェクトを同一とみなして欲しいというときは 適宜 == メソッドを再定義して new == old を行う
class C def initialize(params=nil); @params=params; end def ==(other) self.instance_variables.all? do |e| self.instance_variable_get(e) == other.instance_variable_get(e) end end end
default = C.new c4 = C.new [c1, c2, c3, c4].each do |c| if c == default then puts 'default!' else puts 'modified' end end # => modified, modified, modified, default!