|
| 1 | +Name: symmetric difference |
| 2 | + |
| 3 | +Type: command |
| 4 | + |
| 5 | +Syntax: symmetric difference <targetArray> with <templateArray> [into <destinationArray>] |
| 6 | + |
| 7 | +Summary: |
| 8 | +Removes <element(glossary)|elements> from a target <array> which have a |
| 9 | +corresponding <element(keyword)> in a template <array>, and adds |
| 10 | +<element(glossary)|elements> from the template <array> that have no |
| 11 | +which have no corresponding <element(keyword)> in the target <array>. |
| 12 | + |
| 13 | +Introduced: 9.0 |
| 14 | + |
| 15 | +OS: mac, windows, linux, ios, android |
| 16 | + |
| 17 | +Platforms: desktop, server, mobile |
| 18 | + |
| 19 | +Example: |
| 20 | +local tLeft, tRight |
| 21 | +put "green" into tLeft["color"] |
| 22 | +put "left" into tLeft["align"] |
| 23 | + |
| 24 | +put "blue" into tRight["color"] |
| 25 | +put "100" into tRight["width"] |
| 26 | + |
| 27 | +symmetric difference tLeft with tRight |
| 28 | + |
| 29 | +# RESULT |
| 30 | +# the keys of tLeft = "align" & "width" |
| 31 | +# tRight unchanged |
| 32 | + |
| 33 | +Parameters: |
| 34 | +targetArray (array): |
| 35 | +The value to modify. |
| 36 | + |
| 37 | + |
| 38 | +templateArray (array): |
| 39 | +The array to symmetric difference <targetArray> with. |
| 40 | + |
| 41 | +destinationArray (optional array): |
| 42 | +A variable to set as the destination instead of mutating <targetArray> |
| 43 | + |
| 44 | +Description: |
| 45 | +Use the <symmetric difference> <command> to set the <element(glossary)|elements> |
| 46 | +from an <array> according to the contents of another <array>. |
| 47 | + |
| 48 | +Each key of <targetArray> is checked to see whether there is a matching |
| 49 | +<key> in <templateArray>. The <element(glossary)|elements> of |
| 50 | +<targetArray> that match an <element(keyword)> of the <templateArray> |
| 51 | +are removed from <targetArray> while the <element(glossary)|elements> of |
| 52 | +the <templateArray> that have no corresponding <element(keyword)> in |
| 53 | +the <targetArray> are added to the <targetArray>. |
| 54 | + |
| 55 | +The content of individual elements of the <templateArray> does not |
| 56 | +affect the final result. Only which <element(glossary)|elements> exist |
| 57 | +in the <templateArray>, not their content, controls which |
| 58 | +<element(glossary)|elements> of <targetArray> are retained and which are |
| 59 | +removed. |
| 60 | + |
| 61 | +If the into clause is used the operation of the commands is the same as |
| 62 | +the non-into form except that <targetArray> does not have to be a |
| 63 | +variable, and the result of the operation is placed into |
| 64 | +<destinationArray> rather than mutating <targetArray>. |
| 65 | + |
| 66 | +References: split (command), union (command), element (glossary), |
| 67 | +array (glossary), command (glossary), key (glossary), element (keyword), |
| 68 | +intersect (command), difference (command) |
| 69 | + |
| 70 | +Tags: properties |
0 commit comments