#1464 js: Obj.hash always returns 0

dsav Wed 30 Mar 2011

Default implementation of the hash method always returns 0 in JavaScript.

I tested on the following code:

internal class EmptyObj {  

class HashTest
  static Void hashTest() {
    EmptyObj[] t := [,]
    10.times { t.add(EmptyObj()) }
    t.each { 
      echo("Hash: $it.hash")      

On Java, the hashes differ, on JS they are all 0.

andy Wed 30 Mar 2011

JavaScript doesn't provide hashcodes for Objects like Java/C# - so its gone unimplemented so far - basically relying on reference equality if you haven't overridden your hash/equals.

andy Wed 30 Mar 2011

Promoted to ticket #1464 and assigned to andy

Lets track this as a ticket tho since we need to address this at some point.

andy Tue 8 Nov 2011

Ticket resolved in 1.0.61

Fixed - changeset - see also #1680

dsav Wed 9 Nov 2011

Great! There is also a related issue (http://fantom.org/sidewalk/topic/1485). I assume, it's not hard to fix it now, when hash is implemented. Could you please take a look on this?

Login or Signup to reply.