a - b: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 33: Line 33:
[[Array]]<br>_result = [1,2,2,[[player]],"String"] '''-''' [2,[[player]],[[player]],"String"] ............ _result is [1]
[[Array]]<br>_result = [1,2,2,[[player]],"String"] '''-''' [2,[[player]],[[player]],"String"] ............ _result is [1]


'''Comments:'''<br>
Note that this way of removing elements from an array will not work if those elements are themselves arrays.  For example
[ [0,0,0],[1,1,1],[2,2,2] ] - [1,1,1] will not remove the element [1,1,1] from the first array.<br>


A more practical example: [getPos unit1,getPos unit2,getPos unit3] - getPos unit3<br>
'''Comments:'''
will not remove the position of unit3 from the first array.
 
Note that this way of removing elements from an array will not work if those elements are themselves arrays.
 
For example
 
[ [0,0,0],[1,1,1],[2,2,2] ] - [1,1,1]
 
Will not remove the element [1,1,1] from the first array.
 
A more practical example: [ [[getPos]] unit1, [[getPos]] unit2, [[getPos]] unit3] - [[getPos]] unit3<br>
 
Will not remove the position of unit3 from the first array.

Revision as of 22:59, 2 May 2006


a - b


Operand types:

a: Number or Array

b: Number or Array

Type of returned value:

Number or Array

Description:

For numbers: a minus b.

For arrays: Contents of array b removed from array a.
See also. Array


Examples:

Number
_sum = 10 - 7 ............ _sum is 3


Array
_result = [1,2,2,player,"String"] - [2,player,player,"String"] ............ _result is [1]


Comments:

Note that this way of removing elements from an array will not work if those elements are themselves arrays.

For example

[ [0,0,0],[1,1,1],[2,2,2] ] - [1,1,1]

Will not remove the element [1,1,1] from the first array.

A more practical example: [ getPos unit1, getPos unit2, getPos unit3] - getPos unit3

Will not remove the position of unit3 from the first array.