
|
If you were logged in you would be able to see more operations.
|
|
|
There is no good reason why array equality should work differently from list equality:
groovy> def list1 = [1,2,3,4]
groovy> def list2 = [1,2,3,4]
groovy> assert list1 == list2
groovy> int[] arr1 = [1,2,3,4]
groovy> int[] arr2 = [1,2,3,4]
groovy> assert arr1 == arr2
Exception thrown: java.lang.AssertionError: Expression: (arr1 == arr2). Values: arr1 = [I@bc608f, arr2 = [I@677b56
Equality for lists compares the values, equality for arrays does identity. This seems very counter-intuitive, especially if you are writing code that does not mind whether it gets arrays or lists, and is not "Groovy".
|
|
Description
|
There is no good reason why array equality should work differently from list equality:
groovy> def list1 = [1,2,3,4]
groovy> def list2 = [1,2,3,4]
groovy> assert list1 == list2
groovy> int[] arr1 = [1,2,3,4]
groovy> int[] arr2 = [1,2,3,4]
groovy> assert arr1 == arr2
Exception thrown: java.lang.AssertionError: Expression: (arr1 == arr2). Values: arr1 = [I@bc608f, arr2 = [I@677b56
Equality for lists compares the values, equality for arrays does identity. This seems very counter-intuitive, especially if you are writing code that does not mind whether it gets arrays or lists, and is not "Groovy".
|
Show » |
Sort Order:
made changes - 20/Jan/07 03:27 PM
| Field |
Original Value |
New Value |
|
Assignee
|
Guillaume Laforge
[ guillaume
]
|
|
made changes - 22/Jan/07 01:57 AM
|
Assignee
|
|
Paul King
[ paulk
]
|
made changes - 09/Oct/07 09:08 AM
|
Resolution
|
|
Fixed
[ 1
]
|
|
Fix Version/s
|
|
1.1-rc-1
[ 13165
]
|
|
Status
|
Open
[ 1
]
|
Resolved
[ 5
]
|
made changes - 22/Nov/07 05:24 AM
|
Status
|
Resolved
[ 5
]
|
Closed
[ 6
]
|
|
I have a patch for this which works for Object types but primitive arrays are stored by Groovy in their primitive form and I need to make the patch work with that before submitting.