Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.7, 1.8-beta-4
-
None
-
any
Description
reverse ranges like X..-Y are used in lists to represent forward ranges of the form X..list.size()-Y.
this is not the case with arrays, as these special cases return a list that match the reverse range.
this can easily be tested with this snippet
def list = [1,2,3,4] int[] array = list assert list[2..-1] == [3,4] assert array[2..-1] == [3,4]
which currently yields
Assertion failed: assert array[2..-1] == [3,4] | | | | | false | [3, 2, 1, 4] [1, 2, 3, 4]
we can track this to the protected DGM.primitiveArrayGet(Object,Range) that is called from DGM.getAt(int[],Range) and its siblings.
this method just iterates the range to generate the returned list, whereas the list equivalent DGM.getAt(List,Range) makes use of DGMS.subListBorders(int,Range) to detect the reverse ranges.