Re: An issue about comparing arrays

2016-11-02 Thread Daniel.Sun
I see, it is Groovy's friendly behavior. Thank you, Paul. Cheers, Daniel.Sun 在 "paulk_asert [via Groovy]" ,2016年11月3日 下午2:43写道: We just have to be a little careful. Rightly or wrongly (search the mailing lists for many discussions), current Groovy's '==' tries to do 'friendly coercion' bet

Re: An issue about comparing arrays

2016-11-02 Thread Paul King
We just have to be a little careful. Rightly or wrongly (search the mailing lists for many discussions), current Groovy's '==' tries to do 'friendly coercion' between types to try to give a business domain friendly meaning to equality: String[] one = ['a', 'b', 'c'] List two = ['a', 'b', 'c'] asse

Re: An issue about comparing arrays

2016-11-02 Thread Daniel.Sun
I verified the comparing of Java, which will check the type first. e.g. new int[2][][].equals(new int[2][]) // false new int[2].equals(new long[2]) // false Cheers, Daniel.Sun 在 "bo zhang [via Groovy]" ,2016年11月3日 上午9:24写道: Yes, that's my first instinct too, but a few minutes later I found t

Re: An issue about comparing arrays

2016-11-02 Thread bo zhang
Yes, that's my first instinct too, but a few minutes later I found test cases as follows: assert [[[5, 6], [7, 8]]] as int[][][] == [[[5, 6], [7, 8]]] as Long[][][] See https://github.com/groovy/groovy-core/blob/master/src/test/groovy/ArrayTest.groovy#L207 I think this issue can be discussed, an

Re: An issue about comparing arrays

2016-11-02 Thread Daniel.Sun
IMO, we should compare their type first. If not same, the comparing result should be 'false'. Cheers, Daniel.Sun 在 "bo zhang [via Groovy]" ,2016年11月3日 06:53写道: I'm afraid it's not a bug. Actually, `def a=new int[2][]` means that a is an array of two null pointers with type "int []", and `d

Re: An issue about comparing arrays

2016-11-02 Thread bo zhang
I'm afraid it's not a bug. Actually, `def a=new int[2][]` means that a is an array of two null pointers with type "int []", and `def b=new int[2][][]` means that b is an array of two null pointers with type "int[][]", it seems that they should be equal. See https://github.com/groovy/groovy-core/b