#replacing an item in an arraylist

1 messages · Page 1 of 1 (latest)

ashen scarab
#

how to replace just one item in an arraylist? stdlib doct tell me that there is a replaceRange function. Why no replace function? how can I avoid using replaceRange and making a slice first each time i want to replace just one item?

drifting gust
#

what exactly is it that you want to do?
if you want to replace a single element to a single other element, just access the items and change directly: (arrlist.items[index] = new_item;)
if you want to replace a single element with a sequence of other elements, use repalceRange with the len argument set to 1 (try arrlist.replaceRange(index, 1, new_items);)

ashen scarab
#

ok thanks I wanted to replace one item with another

#

works accessing directly also for an arraylist of arraylists?

drifting gust