insert
- command
- The insert command is used to add values to a list. Inserting is a non-destructive operation — new values are added to the list, but existing values are never removed or replaced.
- The result of an insert command is always a list, even if the container being inserted into wasn't a list to begin with. In this case, the original value is treated as though it were the only value in a single-item list before the insertion takes place.
- insert makes a copy of the values being inserted
- If the value being inserted is also a list, each item of that list is inserted into the destination list, unless nested insertion is specified. Nested insertion can be specified either by using the “nested” keyword in the command, or by setting the listInsertionMode global property to “nested”.
- The insert after command extends a list by inserting one or more new values after the existing list. If the original value in the container was not a list, it will be turned into a list of one item before the insertion takes place:
put "hi" into foo
insert "bye" after foo
put foo —> ("hi","bye")
- Note that this command always treats the container as a list, and inserts a new value (or values) at the end of the list. If the destination is not a list (such as a string, a number, or a property list), it will be converted to a list of one value before the insertion takes place.