Operators: &

AND operator.

Syntax

integer‑operand&integer‑operand

rect‑operand&rect‑operand

styles‑operand&styles‑operand

user‑defined‑set‑operand&user‑defined‑set‑operand

Bitwise AND

In its first version, the & operator performs on the both operands a bitwise AND operation. 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 uint32 a = 0xFF003AC0; var uint32 b = 0xAB15FF70; var int32 c = 1369; // = 0x00000559 var int32 d = -1496; // = 0xFFFFFA28 var uint32 result = a & b; // result = 0xAB003A40 var int32 result = c & d; // result = 8 var uint32 result = a & d; // result = 0xFF003A00

Rectangle intersection

In its second version, the & operator performs a rectangle intersection. The result is a new rectangle representing an area contained within the left AND the right rect operand. The operator results in an empty rectangle (isempty) if the both rectangles don't intersect. For example:

var rect a = <10,5,110,220>; var rect b = <-10,-50,50,75>; var rect c = <110,5,120,220>; var rect result = a & b; // result = <10,5,50,75> var rect result = b & a; // result = <10,5,50,75> var rect result = a & c; // result = empty rectangle

Please note the operator && containing an alternative, more advanced implementation of the rectangle intersection.

Styles intersection

In its third 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 only those elements which exist in the left AND in the right operand. 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 = [ Style3, Style16 ] var styles result = b & c; // result = []

Set intersection

In its fourth 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 only those elements which exist in the left AND in 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[ ResizeHorz ] var Core::Layout result = b & c; // result = Core::Layout[]