I was wondering how can I change the value of an element in a list in Io language?
l := list(4, 6, 3, 8, 10)
list(4, 6, 3, 8, 10)
I want to change it to:
list(4, 5, 3, 8, 10)
One way is to use insertAt()
and removeAt()
, But I want to know whether there is another way or not.
l removeAt(1)
l insertAt(5, 1)
Any idea?
You can do:
l atPut(1, 5)
This will replace index 1 with the value 5.