See the sample code first:
arr = [4, 5, 6]
arr[2] = ["a","b","c"] # First Update
print arr.join(","), ", len=", arr.length, "\n"
print arr[2] ,"\n"
arr[0..1] = [7,"h","b"] # Second Update
print arr.join(","), ", len=", arr.length, "\n"
Output is:
4,5,a,b,c, len=3
abc
7,h,b,a,b,c, len=4
With the first update, only element 2 is updated to "abc". But with the second update, updating 3 elements to 2 existing elements leads to insert one element, so array length increase 1.
My question is that why the first update doesn't lead to element insertion? What's the rule?