Operators in groovy
In groovy, operators are symbols which are used to tell the compiler to perform specified operations.
Following are the operators in groovy:
Arithmetic operators are the basic mathematical operators, which are used to perform addition, subtraction, multiplication, division, Remainder and Power.
In groovy, we also have some functions which are used to perform Arithmetic operations like plus, minus, intdiv and power. The use of these functions are shown in the example which is given below.
In groovy, Unary operators require only one operator to perform the operation. Unary operators are used to perform the operations such as increment/decrement, negating, and inverting the values of a Boolean.
Assignment arithmetic operators
In groovy, assignment arithmetic operators are used to assign a new value to the variable.
In groovy, relational operators are used to compare two objects to check wether they are same or different or one is greater than, less than or equal to other object.
In groovy, there are 3 logical operators for Boolean expression, and these operators are AND(&&), OR(||) and NOT(!)
Note: In groovy, logical "not" is having a higher priority as compared to the logical "and".
Note: In groovy, logical "and" is having a higher priority as compared to the logical "or".
In groovy, Bitwise operators are used for operating on binary digits or bits of an integer.
In groovy, there are three types of conditional operators they are as follow:
In groovy, "not" operator is used invert the result of the Boolean expression.
In groovy, Ternary Operator is the shortcut of if/else
In groovy, Elvis operator is a shorthand property of the ternary operator. It only returns when a value is true.