Re: [Ironruby-core] object equality

2010-09-10 Thread Tomas Matousek
Subject: Re: [Ironruby-core] object equality great to hear, and already looking forward to the next release :) just wondering though, you mentioned that it's possible to provide your own implementation of !=. how would one do that? if i try to define a != method, i get an 'unexpected !=

Re: [Ironruby-core] object equality

2010-09-10 Thread Davy Brion
le != 100)); > > Assert((bool)( equatable != 100)); > > > > Tomas > > > > *From:* ironruby-core-boun...@rubyforge.org [mailto: > ironruby-core-boun...@rubyforge.org] *On Behalf Of *Davy Brion > *Sent:* Thursday, September 09, 2010 4:46 AM > *To:* ironruby-co

Re: [Ironruby-core] object equality

2010-09-09 Thread Tomas Matousek
There is indeed a typo… the last line should read: Assert((bool)( equatable != 101)); Tomas From: Tomas Matousek Sent: Thursday, September 09, 2010 10:10 PM To: ironruby-core@rubyforge.org Subject: RE: [Ironruby-core] object equality If any of the operands of == or != are typed to dynamic C

Re: [Ironruby-core] object equality

2010-09-09 Thread Tomas Matousek
ert(!(bool)( equatable != 100)); Assert((bool)( equatable != 100)); Tomas From: ironruby-core-boun...@rubyforge.org [mailto:ironruby-core-boun...@rubyforge.org] On Behalf Of Davy Brion Sent: Thursday, September 09, 2010 4:46 AM To: ironruby-core@rubyforge.org Subject: Re: [Ironruby-core] object equalit

Re: [Ironruby-core] object equality

2010-09-09 Thread Davy Brion
On Thu, Sep 9, 2010 at 1:44 PM, Davy Brion wrote: > by default, == does a reference check in C#, unless you override it to do a > value based check (which you typically implement in Equals) > > in C#, if you want == and != to work properly you need to implement them > both. In ruby, you obviousl

Re: [Ironruby-core] object equality

2010-09-09 Thread Davy Brion
by default, == does a reference check in C#, unless you override it to do a value based check (which you typically implement in Equals) in C#, if you want == and != to work properly you need to implement them both. In ruby, you obviously can't implement !=, but i had (naievely perhaps) expected t

Re: [Ironruby-core] object equality

2010-09-09 Thread William Green
Then it would appear that in C#, using the != operator on two instances of Ruby objects does not call the == method on the first Ruby object and invert the result. Can you switch to using equals as a work-around? Not sure of the semantics around == vs .Equals in C#, but I know there is a semantic

Re: [Ironruby-core] object equality

2010-09-09 Thread Davy Brion
the problem isn't with checking wether 2 objects are equal (though you indeed need to define an Equals method on your ruby object if you want the comparison to work with a direct call to .Equals... doing == in C# definitely uses the == method of your ruby object) but it is with the != check. In ru

Re: [Ironruby-core] object equality

2010-09-09 Thread William Green
Testing for object equality in C# is different than it is in Ruby. In C#, you need to override both Object.Equals and Object.GetHashCode (I forget which is used when, but I do recall that the compiler complains if you override one and not the other). So, when you bring your Ruby object into C# and