Operators

Operators

An operator, in a programming language, is a symbol that represents an action. It tells the program to perform specific mathematical, relational, logical or assignment actions on given values to produce a final result. The values on which the action is performed are known as the operands. The operands can be Zoho Creator fields, variables declared in Deluge or expressions.

Example:

(7 * 7) + 4 = 53
"Hello" + "world" = "Hello world" // concatenates string values

The different types of operators are:

 Arithmetic Operators

An arithmetic operator, operates on one or two numeric value and returns a numeric value.

Syntax

<op1> <Operator> <op2>

where, <op1> and <op2> are both numeric expressions. The table below lists the binary arithmetic operators and their functionality:

OperatorSyntaxDescription
+x + yAddition operator: Adds the value of x to the value of y.
  • If x and y are Integers or Doubles, adds the value of x to the value of y. If a Double is used, the result is a Double.
  • If x is a Date or Date-Time and y is an Integer, returns a new Date that is incremented by the specified number of days.
  • If x is a Date or Date-Time and y is an Integer, returns error "Left expression is of type TIMESTAMP and right expression is of type BIGINT and operator + is not valid"
  • If x and y is a string, concatenates y to the end of x.
-x - y

Subtraction operator: Subtracts the value of y from the value of x.

  • If x and y are Integers or Doubles, subtracts the value of y from the value of x. If a Double is used, the result is a Double.
  • If x is a Date or Date-Time and y is an Integer, returns a new Date that is incremented by the specified number of days.
  • If x is a Date or Date-Time and y is an Integer, returns error "Left expression is of type TIMESTAMP and right expression is of type BIGINT and operator + is not valid"
*x * ymultiplies <op1> and <op2>
/x / ydivides <op1> by <op2>
%x % yremainder when dividing <op1> by <op2>

 Relational Operators

A relational operator compares two values and returns a boolean expression (true or false) depending on the relation between the two values.

Example

5 > 4 -> true
233.6 < 94.22 -> false

Syntax

<op1> <Operator> <op2>

The table below lists the binary arithmetic operators and their functionality:

OperatorFunctionality
><op1> is greater than <op2>
>=<op1> is greater than or equal to <op2>
<<op1> is less than <op2>
<=<op1> is less than or equal to <op2>
==<op1> is equal to <op2>
!=<op1> is not equal to <op2>

 Conditional Operators

Relational operator combined with conditional operators, make your decision making more powerful. A conditional operator operates on boolean expression and each boolean expression may contain relational operator or conditional operator, thus enabling us to write complex decision logics. Deluge supports the conditional operators '&&' , '||' and '!'.

Syntax

<boolean expression> && <boolean expression>
<boolean expression> || <boolean expression>
! <boolean expression>

where,

'&&' - returns true only if both the left and right boolean expressions are true.
'||' - returns true if atleast one of the boolean expression evaluates to true.
'!' - returns true if the boolean expression is false and vice-versa.

OperatorFunctionality
&&Both the left and right boolean expressions are true
llAtleast one of the boolean expression is true
!boolean expression is false

 Assignment Operators

To assign values to the left operand, with or without performing arithmetic operations, based on the value of the right operand

Example

x += 1    
// x = x + 1 = 3

The table below lists the binary assignment operators and their functionality:

OperatorExample
=x = 2   // assigns the value 2 to x.
+=x += 1     // x = x + 1 = 3
-=x -= 1      // x = x - 1 = 2
*=x *= 1      // x = x * 1 = 2
/=x /= 1      // x = x / 1 = 2
%=x %= 1    // x = x % 1 = 0

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com