Affects Version/s: 1.6-beta-2
Fix Version/s: 1.7-beta-1
Groovy's list-indexing semantics originally came from Ruby, where x[2,5] means the same as x[2 ..< 5]. However, at some point it was changed r-values (getAt()), but never for l-values (putAt()). So currently we have this:
x = [4, 5, 6, 7]
assert x[1, 3] == [5, 7]
x[1, 3] = 55
assert x == [4, 55]
If you try to index with a list of any length other than two, you get an exception, but only as an l-value, not an r-value.
The proposal is that x[list1] = list2 should succeed when list1 has the same number of elements as list2, replacing the corresponding elements, and throw an exception otherwise. Also x[list1] = nonlist should replace all elements that have the specified indices with the given nonlist element.
This was discussed on the groovy-dev mailing list, subject "Bug or Feature?", starting Nov. 12, 2008.
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|12d 2h 33m||1||Martin C. Martin||29/Dec/08 11:56|
|290d 5h 21m||1||Paul King||15/Oct/09 18:17|
|Workflow||jira [ 12970108 ]||Default workflow, editable Closed status [ 12977866 ]|
|Project Import||Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]|
|Workflow||jira [ 12732210 ]||Default workflow, editable Closed status [ 12744074 ]|
|Project Import||Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]|
|Status||Resolved [ 5 ]||Closed [ 6 ]|
|Field||Original Value||New Value|
|Fix Version/s||1.6 [ 13832 ]|
|Status||Open [ 1 ]||Resolved [ 5 ]|
|Fix Version/s||1.7-beta-1 [ 14014 ]|
|Resolution||Fixed [ 1 ]|