Water 5-Common Data Types-Generic Object and CollectionContract| Return type | wob | | Parameter key | Default value | Type | | include | return_false | var | | shift | true | boolean | | if_missing | "error" | string | | default | null | | Parameter kind | Default value | Type | | Other unkeyed arguments | opt | | Water Contract<method remove
include =return_false
shift =true
if_missing="error"
default =null
_other_unkeyed=opt=wob=ekind.code="_body"/> | |
Removes the fields designated by the _other_unkeyed arguments and the include argument
from _subject and returns the value of the last field removed.
If the field cannot be removed, such as when it does not exist or is
inaccessible, the behavior is controlled by the if_missing argument.
If it is "error" , the default, then remove errors with a message
containing the string in the default argument.
If it is "return" then the value of the default argument is returned.
Note that you cannot remove any fields from primitive objects because
they do not have any fields.
If shift is true , (the default), then if key is an integer
of less than the object size and more than or equal to 0, then not only is
the field removed but the higher integer-named fields are all moved down by one.
In this case even though the remove was successful,
there may exist a field of the given name after this operation because
higher integer fields will be moved down.
If the _subject is a vector, the shift argument must be true .
Removing vector key fields is tricky. If you remove several as in
<thing 0=100 1=200 2=200/>.<remove 2 1 0/>
 | 100 |
make sure that you remove the highest key first so that it won't
shift the others down, or do:
<thing 0=100 1=200 2=200/>.<remove shift=false 0 1 2/>
 | 200 |
but beware that may leave gaps in the vector.
If you do:
<thing 0=100 1=200 2=200/>.<remove include=vector_key shift=false/>
 | 200 |
make sure to shift=false or the shifting problem will cause an error
of attempting to remove non-existent fields.
If you do not pass a field name to remove, and you leave include at its default
of return_false , then the field at the index of
one less than the length of the object will be removed and is returned,
thus performing the pop functionality.
<set foo55=<vector 3 4 5/>/>
<v
foo55.<remove/>
foo55
/> | <v 5 <vector 3 4/>/>
|
The opposite method is insert .
© Copyright 2007 Clear Methods, Inc.