Modifying An Array
OSL is a 1 indexed scripting language, meaning that arrays start at the index 1 not at 0 like many other languages.
Setting Items Of An Array
You can set or update an item of an array using any way of assignment shown here
Setting Nested Items
In osl you can update nested items using multiple stacked references to a part of an object/array that gets compiled into a simple json path.
Appending And Prepending
To append and prepend to an array, you can not only use the +
operator in Array Operations but you can also use the .prepend(val) and .append(val) methods
Delete An Item Of An Array
To remove an item from an array, you can use either the .delete(location) method or .pop() to remove the last item, or .shift() to remove the first item.
Last updated