Polar Script supports the following operators
Operator | Name | Notes |
---|---|---|
+ | Add | Add two numbers. The resulting type is the most 'generous' type of the given types. |
- | Subtract | Subtract the second number from the first number. The resulting type is the most 'generous' type of the given types. |
/ | Divide | Divide the first number by the second number. The resulting type is a Double |
\ | Integer divide | Divide the first number by the second number and round down. The resulting type is a Long |
* | Multiply | Multiply two numbers. The resulting type is the most 'generous' type of the given types. |
^ | Power | a^b results in a to the power of b. Returns a Double |
Mod | Remainder | Returns the remainder of expression 1 divided by expression 2. Both values are first rounded to the nearest whole number before the operation is evaluated. The result is a Long |
% | Remainder | Returns the remainder of expression 1 divided by expression 2. Is like Mod, however, this version uses unrounded Doubles. |
& | Concatenate | Concatenate two expressions. Returns a String |
Not | Bitwise Not | Inverts the bits in the given number. If a boolean is passed, a boolean is returned. If a Long is passed, a Long is returned. |
! | Boolean Not | Returns the boolean opposite of the passed value (always True or False) |
And | Bitwise And | Returns a bitwise AND for to Long values or a Boolean if both values were boolean |
&& | Boolean And | This shortcutted Boolean AND returns the Boolean result of expression 1 AND expression 2. This operator is 'shortcutted' meaning Expression 2 is only evaluated if Expression 1 returned True. |
Or | Bitwise Or | Returns a bitwise OR for to Long values or a Boolean if both values were boolean |
|| | Boolean Or | This shortcutted Boolean OR returns the Boolean result of expression 1 OR expression 2. This operator is 'shortcutted' meaning Expression 2 is only evaluated if Expression 1 returned False. |
Xor | Bitwise Or | Returns a bitwise Exclusive-OR for to Long values or a Boolean XOR result if both values were boolean |
= == | Equals | Returns a boolean indicating value 1 equals value 2. Please note that == does exactly the same as = and is added to allow programmers to use C#/C++/Javascript alike expressions. |
> | Greater than | Returns a boolean indicating value 1 is greater than value 2 |
>= | Greater than or equals | Returns a boolean indicating value 1 is greater than value 2 |
< | Lesser than | Returns a boolean indicating value 1 is lesser than value 2 |
<= | Lesser than or equals | Returns a boolean indicating value 1 is lesser than or equal to value 2 |
<> != | Not equals | Returns a boolean indicating value 1 is not equal to value 2 |
Is | Is | Returns a boolean indicating object 1 is the same object as object 2 |
IsNot | Is not | Returns a boolean indicating object 1 is not the same object as object 2 |
Like LikeCI NotLike NotLikeCI | Like Like case-insensitive | Returns a Boolean indicating the String in Expression 1 is (not) like the String-pattern given in Expression 2 |
Contains ContainsCI NotContains NotContainsCI | Contains Contains case-insensitive | Returns a Boolean indicating the String in Expression 1 (not) contains the String given in Expression 2 |
StartsWith StartsWithCI NotStartsWith NotStartsWithCI | Starts with Starts with case-insensitive | Returns a Boolean indicating the String in Expression 1 (not) starts with the String given in Expression 2 |
EndsWith EndsWithCI NotEndsWith NotEndsWithCI | Ends with Ends with case-insensitive | Returns a Boolean indicating the String in Expression 1 (not) ends with the String given in Expression 2 |
In InCI NotIn NotInCI | In array In array case-insensitive | Returns a Boolean indicating the Array given in Expression 2 (not) contains an element that is equal to the value of Expression 1. For object variables, not the values are compared, but only if the exact object from Expression 1 is contained in the array in Expression 2. For InCI / NotInCI, Expression 1 must be a String and the array is expected to contain strings as well. |
?? | Coalesce | Evaluates expression 1. If this value is NOT an empty value then this value is returned. Else expression 2 is evaluated and its result is returned. |
??? | String Coalesce | Evaluates expression 1 and converts to a string. If the result is NOT an empty string then this value is returned. Else expression 2 is evaluated and its result is returned as a string. |