Water 5-Common Data Types-Generic Object and CollectionContract| Return type | wob | | Parameter key | Default value | Type | | at_key | "end" | string | | Parameter kind | Default value | Type | | Other unkeyed arguments | opt | | Water Contract<method insert
at_key="end"
_other_unkeyed=opt=wob=ekind.code="_body"/> | |
Inserts one or more elements into the vector of _subject at at_key.
Returns the subject, or in the case that the subject is a string,
returns a new string with the inserted chars.
<vector 10 11 12/>.<insert at_key=1 88/>
 | <vector 10 88 11 12/>
|
<vector 10 11 12/>.<insert at_key=1 88 99 />
 | <vector 10 88 99 11 12/>
|
<vector 10 11 12/>.<insert at_key=1 _args=<vector 88 99/> />
 | <vector 10 88 99 11 12/>
|
Giving insert an explicit _args argument effectively "appends" the _args vector onto the end
of _subject
If at_key is "end" , add the new elements at the end of the vector, i.e. the push operation.
at_key is opt and insert takes _args so at_key must be explicitly named if used.
If at_key is not used, it defaults to "end" .
<set a=<vector 10 11 12/>> a.<insert 13/> a </set>
 | <vector 10 11 12 13/>
|
If _subject is a string then the _other_unkeyed args are expected to be chars or strings.
A new string is made containing the subject chars with the _other_unkeyed chars inserted
at the proper location:
"abc".<insert "def"/>
"abcdef" "abc".<insert "def" "gh"/>
"abcdefgh" "abc".<insert "def" "gh" at_key=1/>
 | "adefghbc" |
"abc".<insert <char "d"/>/>
"abcd" "abc".<insert _args=<vector <char "d"/> <char "e"/> />/>
 | "abcde" |
You can also have a subject of a file and give string args to be inserted into
the content of the file at the at_key position.
To return a new vector (and avoid modifying an existing vector),
first copy the vector before calling insert.
<vector 10 11/>.<copy/>.<insert 12/>
 | <vector 10 11 12/>
|
© Copyright 2007 Clear Methods, Inc.