31 | | |
| 32 | '''push_if(boolean, element...)''' |
| 33 | |
| 34 | This function behaves exactly like push() except that the first argument determines whether or not to add the rest of the arguments to the value of self. If the value is false, the function will return an empty list. As for push(), this function will create a new list if self is undefined. See also the warning about multiple calls to push() within the same DML block; this warning also applies here. |
| 35 | |
| 36 | '''npush(element...)''' |
| 37 | |
| 38 | This function will return a copy of self with the given value(s) inserted into the nlist. The number of arguments must be even; each pair will be treated as a key/value. If self is undefined, the function will create a new nlist with the arguments and return that. An example is |
| 39 | {{{ |
| 40 | '/mylist' = npush('a',1); |
| 41 | '/mylist' = npush('b',2); |
| 42 | }}} |
| 43 | The final value for '/mylist' will be a two-element nlist containing the key/value pairs ('a',1) and ('b',2). |
| 44 | |
| 45 | Be careful because the value of self is not directly modified by the npush() function. This means that the following: |
| 46 | {{{ |
| 47 | '/mylist' = { |
| 48 | npush('a',1); |
| 49 | npush('b',2); |
| 50 | }; |
| 51 | }}} |
| 52 | will leave '/mylist' with the one-element nlist with the key/value pair ('b',2). |
| 53 | |