Operators: +
Plus operator.
Syntax
Unary form:
+integer‑operandor+float‑operandor+point‑operand
Binary form:
integer‑operand+integer‑operand
float‑operand+float‑operand
point‑operand+point‑operand
rect‑operand+point‑operandorpoint‑operand+rect‑operand
color‑operand+color‑operand
string‑operand+string‑operand
string‑operand+char‑operandorchar‑operand+string‑operand
styles‑operand+styles‑operand
user‑defined‑set‑operand+user‑defined‑set‑operand
Unary positive prefix
The its first, unary version the + operator expects one signed integer, unsigned integer, floating-point or point operand and results in the unchanged, original value of this operand. The resulting data type of the operation corresponds to the original type of the operand. For example:
var float a = -1369.1251; var uint32 b = 4032; var point c = <100,-200>; var float result = +a; // result = -1369.1251 var uint32 result = +b; // result = 4032 var point result = +c; // result = <100,-200>
Integer addition
In its second version, the + operator calculates an arithmetic sum of the both operands. If used with two signed integer operands, the resulting data type is always int32. In all other cases, the operation results in the unsigned uint32 value. For example:
var int32 a = 1369; var int32 b = -1496; var uint32 c = 1369; var uint32 d = 1251; var int32 result = a + b; // result = -127 var uint32 result = c + d; // result = 2620 var uint32 result = b + d; // result = 0xFFFFFF0B
Floating point addition
In its third version, the + operator calculates an arithmetic sum of the both floating-point operands. The resulting data type of the operation is always a float. For example:
var float a = 1369.1251; var float b = -1496.158; var float result = a + b; // result = -127.03295
Point addition
In its fourth version, the + operator calculates an arithmetic sum of the both point operands. The operation is performed individually for the x and y point elements. The addition of two point operands can be considered as a translation of the point in the left operand by an offset specified in the right operand. The resulting data type of the operation is always a point. For example:
var point a = <100,200>; var point b = <50,70>; var point result = a + b; // result = <150,270>
Rectangle positive displacement
In its fifth version, the + operator translates a rectangle operand by an offset specified in the point operand. During the operation, the x and y point elements are added to the corresponding coordinates of the rectangle's top-left and bottom-right corners. The resulting data type of the operation is always a rect. For example:
var rect a = <100,200,110,220>; var point b = <50,70>; var rect result = a + b; // result = <150,270,160,290> var rect result = b + a; // result = <150,270,160,290>
Color addition with saturation
In its sixth version, the + operator calculates an arithmetic sum of the both color operands. The operation is performed individually for every red, green, blue and alpha color components by respecting the upper limit of the value range 0 .. 255. The resulting data type of the operation is always a color. For example:
var color a = #10C050F0; var color b = #225F22E0; var color result = a + b; // result = #32FF72FF
String concatenation
In its seventh version, the + operator creates a copy of the left string operand followed by the copy of the string in the right operand. This results in the both strings being concatenated. The resulting data type of the operation is always a string. Similarly, a string and a char operand ca be concatenated to a new string. For example:
var string a = "Hello"; var string b = "World"; var char c = '!'; var string result = a + " " + b + c; // result = "Hello World!"
Styles union
In its ninth version, the + operator combines the both styles operands to a new styles value. Please note, styles operands can be considered as collections containing multiple elements you can individually include or exclude. Thus, the + operation results in a new styles value including all elements from the left and the right operands. The resulting data type of the operation is always styles. For example:
var styles a = [ Style1, Style3, Style16 ]; var styles b = [ Style3, Style16 ]; var styles c = [ Style1, Style8 ]; var styles result = a + b; // result = [ Style1, Style3, Style16 ] var styles result = b + c; // result = [ Style1, Style3, Style8, Style16 ]
Set union
In its tenth version, the + operator combines the both user-defined set operands to a new set value. Please note, set operands can be considered as collections containing multiple elements you can individually include or exclude. Thus, the + operation results in a new set value including all elements from the left and the right operand. The resulting data type of the operation corresponds to the data type of the operands. For example:
var Core::Layout a = Core::Layout[ AlignToTop, ResizeHorz ]; var Core::Layout b = Core::Layout[ ResizeHorz ]; var Core::Layout c = Core::Layout[ AlignToTop, ResizeVert ]; var Core::Layout result = a + b; // result = Core::Layout[ AlignToTop, ResizeHorz ] var Core::Layout result = b + c; // result = Core::Layout[ ResizeHorz, AlignToTop, ResizeVert ]