Professional Documents
Culture Documents
• Getting Started
Welcome!
Variables
Data Types
Operators
Expressions
Comments
Conditional Statements
List
Map
Getting Started
• Welcome
Syntax
info <expression>;
info is used as a debugger statement which would print out the given expression on the output
console.
Example
info "Hi, there!!";
Check out the following example which would create a variable name with value as "John".
Example
name = "John";
info name;
TRY IT OUT
Create a variable product_name and set it's value as "Milk" and Try to print the value of the variable.
product_name = "Milk";
info product_name;
Data Types
Now we'll learn about different types of variables which we can create in deluge script. The static values are nothing but known as
constants.
Follow the given example which would create a variable of type number(Bigint), float (Decimal) and boolean (Bool) in order (Other data
types will be covered later).
Example
age = 22; // Bigint
pi = 3.14; // Decimal
isWeekend = false; // Bool
TRY IT OUT
Create another variable product_quantity with value as 5 , product_price with value as 20.50 & isAvailable with value as true.
Try to print their values too in the same order.
product_name = "Milk";
product_quantity = 5;
product_price = 20.5;
isAvailable = true;
Operators
Operators are used to compute arithmetic operations between two operands (i.e variable or any constant).
Example
C = 39;
F = C * 9/5 + 32;
info F;
TRY IT OUT
Create a variable price with value 85 and quantity with value 6. Now try to find out the Total
price.
price = 85;
quantity = 6;
Total_Price= price * quantity;
info Total_Price;
OUTPUT
510
Expressions
Combinations of variables, constants and operators are expressions. Following example shows how to concatenate firstName
and lastName as fullName and to find the length of it.
Example
first_name = "John";
last_name = "Smith";
full_name = first_name + last_name;
//Put a dot to apply function on a variable
info full_name.length();
TRY IT OUT
Create a variable product_name with value as Milk Powder. Now print the value of product_name in lowercase.
product_name = "Milk Powder";
info product_name.lower();
OUTPUT
milk powder
Comments
Syntax
// <write your comments here> Single Line
/*
Multiline comments are used for large text descriptions or to comment out chunks
of code.
*/
Comments generally help to understand the code better and the commented out code will never be
executed.
Example
// name = "John";
name = "John Smith";
/*
It's a holiday !!
Have Fun !!
*/
isWeekend = true;
// product_price =500
product_price=500;
info product_price;
CONDITIONAL STATEMENTS
if
Syntax
if ( <condition> )
{
// Executes if condition is true
<statements>
}
Conditional Statements execute the mentioned condition and if it evaluates to true then the statments mentioned in the block
will be executed, otherwise execution proceeds to the next block of statement if exists.
Example
marks = 70;
if (marks >= 40)
{
info "Pass !!";
}
TRY IT OUT
Check if product_quantity is greater than equal to 1 then print "Available".
product_quantity = 5;
if (product_quantity >=5)
{
info "Avaialable";
}
CONDITIONAL STATEMENTS
else
Syntax
if ( <condition> )
{
// Executes if condition is true
<statements>
}
else
{
// Executes if condition is false
<statements>
}
Else is a branch of if statement. If the given condition is false, the statements specified under else block will be executed.
OUTPUT
Milk,Bread