Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.0
-
None
-
None
-
groovy-1.0 on jre1.6.0 on WinXP prof edn
Description
//Using both integers and ranges as list subscripts OK when within existing list size...
list = ['a','b','c']; list[1] = 'x'; assert list == ['a','x','c']
list = ['a','b','c']; list[3] = 'x'; assert list == ['a','b','c','x']
list = ['a','b','c']; list[1..2] = ['x','y']; assert list == ['a','x','y']
//but only integers OK when outside existing list size...
list = ['a','b','c']; list[4] = 'x'; assert list == ['a','b','c',null,'x']
//Ranges as list subscripts outside existing list size cause an out-of-bounds exception...
list = ['a','b','c']; try
catch(Throwable e)
{ assert e instanceof IndexOutOfBoundsException }list = ['a','b','c']; try{ list[4..5] = ['x','y'] }catch(Throwable e){ assert e instanceof IndexOutOfBoundsException }
//The desired behavior is:
list = ['a','b','c']; list[2..3] = ['x','y']; assert list == ['a','b','x','y']
list = ['a','b','c']; list[4..5] = ['x','y']; assert list == ['a','b','c',null,'x','y']