difference

Typecommand
DictionaryLCS
LibraryLiveCode Script
Syntax
difference <targetArray> with <templateArray> [into <destinationArray>]
Summary

Removes elements from an array which have a corresponding element in another array, and leaves all others alone.

Introduced9.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
targetArray

The value to modify.

templateArray

The array to difference targetArray with.

destinationArray

A variable to set as the destination instead of mutating targetArray

Example
local tLeft, tRight
put "green" into tLeft["color"]
put "left" into tLeft["align"]

put "blue" into tRight["color"]
put "100" into tRight["width"]

difference tLeft with tRight

# RESULT
# the keys of tLeft = "align"
# tRight unchanged
RelatedCommand: split, union, intersect, symmetric difference
Glossary: element, array, command, key
Keyword: element
Description

Use the difference command to filter out elements from an array according to the contents of another array.

Each key of targetArray is checked to see whether there is a matching key in templateArray. The elements of targetArray that match an element of the templateArray are removed from targetArray.

The content of individual elements of the templateArray does not affect the final result. Only which elements exist in the templateArray, not their content, controls which elements of targetArray are retained and which are removed.

If the into clause is used the operation of the commands is the same as the non-into form except that targetArray does not have to be a variable, and the result of the operation is placed into destinationArray rather than mutating targetArray.

Tagsproperties