[Ironruby-core] object equality

Davy Brion ralinx at davybrion.com
Thu Sep 9 04:33:23 EDT 2010


If i have the following class in ruby:

class TestClass
  def initialize(value)
    @value = value
  end

  def ==(other)
    return false if other.nil?
    self.value == other.value
  end

  protected

  def value
    @value
  end
end

test1 = TestClass.new(5)
test2 = TestClass.new(5)
p test1 == test2
p test1 != test2

the output is:
true
false

if i do this in .NET:

dynamic test1 = ruby.TestClass. at new(5);
dynamic test2 = ruby.TestClass. at new(5);

var equals = test1 == test2;
var differs = test1 != test2;

both equals and differs are true

i'm going to create an issue about this, but i do need to get this
working... is there a temporary workaround that i can use for now?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100909/a416fa3b/attachment.html>


More information about the Ironruby-core mailing list