[ https://issues.apache.org/jira/browse/GROOVY-8929?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16722979#comment-16722979 ]
Paul King commented on GROOVY-8929: ----------------------------------- We follow Java's practice here: https://stackoverflow.com/questions/744735/java-array-hashcode-implementation TL;DR: you want to use {{Arrays.hashCode(a)}} etc. in this case. > Inconsistent equals and hashCode for arrays > ------------------------------------------- > > Key: GROOVY-8929 > URL: https://issues.apache.org/jira/browse/GROOVY-8929 > Project: Groovy > Issue Type: Bug > Affects Versions: 2.4.14 > Reporter: Albert Fernández Marsal > Priority: Major > > {code} > 09:29:~$ groovysh > Groovy Shell (2.4.14, JVM: 1.8.0_171) > Type ':help' or ':h' for help. > --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > # int[] > groovy:000> a = [1,2,3] as int[] > ===> [1, 2, 3] > groovy:000> a.class > ===> class [I > groovy:000> b = [1,2,3] as int[] > ===> [1, 2, 3] > groovy:000> b.class > ===> class [I > groovy:000> a == b > ===> true > groovy:000> a.hashCode() > ===> 1329315688 > groovy:000> b.hashCode() > ===> 1489933928 > # String[] > groovy:000> c = ['a', 'b'] as String[] > ===> [a, b] > groovy:000> d = ['a', 'b'] as String[] > ===> [a, b] > groovy:000> c == d > ===> true > groovy:000> c.hashCode() > ===> 319689067 > groovy:000> d.hashCode() > ===> 6422064 > groovy:000> > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)