Assignment of native VBScript arrays copies. Evidence:
>> Dim a : a = Split("a b c")
>> Dim b : b = a
>> b(0) = "A"
>> WScript.Echo Join(a)
>> WScript.Echo Join(b)
>>
a b c
A b c
Split() returns a VBScript array. You can assign it to list(0), but that gives list(0) a copy. Evidence:
>> Dim list : Set list = CreateObject("System.Collections.ArrayList")
>> Dim a : a = Split("a b c")
>> list.Add a
>> a(0) = "A"
>> WScript.Echo Join(a)
>> WScript.Echo Join(list(0))
>>
A b c
a b c
Your expression list.item(0)
- or with less fuss: list(0)
- in the statement
list.item(0)(0) = "Cherry"
refers to a copy of the array in list, assigning "Cherry" to its first element won't change the 'original' in list. Evidence: Your code.
What can you do?
(1) Get a copy from list(0), change the copy, assign the (full) copy to list(0):
>> Dim list : Set list = CreateObject("System.Collections.ArrayList")
>> Dim a : a = Split("a b c")
>> list.Add a
>> Dim b : b = list(0)
>> b(0) = "Cherry"
>> list(0) = b
>> WScript.Echo Join(list(0))
>>
Cherry b c
(2) Avoid VBScript arrays, use ArrayLists (or Dictionaries, or whatever collection that is not copied on assign) instead:
>> Dim list1 : Set list1 = CreateObject("System.Collections.ArrayList")
>> Dim list2 : Set list2 = CreateObject("System.Collections.ArrayList")
>> list2.Add "Banana"
>> list2.Add "Apple"
>> list1.Add list2
>> WScript.Echo Join(list1(0).ToArray())
>> list1(0)(0) = "Cherry"
>> WScript.Echo Join(list1(0).ToArray())
>>
Banana Apple
Cherry Apple