Collections enhancement: writable iterators. You can now update the value of an element in a collection via direct assignment to the iterator. For example, the following foreach loop updates the value of each element by appending "-updated" to it:
dimx $foo, ordmapm(varstr;varstr)
...
foreach $$i in $foo()
$$i += "-updated"
next $$i
Notes:
• This technique works with all collection types (ORDMAP, ORDMAPM, MLIST).
• In the case of ORDMAPM, it is the only way to change the value of an existing element for which there are duplicate keys.
• In the case of ORDMAP, the direct assignment to the iterator in the above example would be equivalent to ...
$foo(.key($$i)) += "-updated"
... except much faster, since the key lookup, deletion, and re-addition steps are all eliminated.
• In the case of MLIST, it eliminates the need for the .ref($$i) function, (which is now effectively deprecated).
• The iterator is only writeable when it appears on the left side of the equals sign in an assignment statement. In all other cases, particularly when passing an iterator as an argument to a function, it remains read-only.