Skip to main content

Basic statements in Rell

In Rell, the fundamental building blocks of programming are encapsulated within basic statements. These statements enable you to perform a wide range of operations, from assigning values to variables to executing functions and controlling program flow.

Assignment statements

Assignment statements allow you to assign values to variables or data structures. This is a core operation for manipulating data within your program. Examples include:

x = 123;
values[i] = z;
y += 15;

Here, you set the value of x, assign z to an element in the values array, and increment the value of y by 15.

Function call statements

Function call statements involve invoking functions or procedures to execute specific tasks. For instance:

print('Hello');

In this example, the print function is called, outputting "Hello" to the console.

Return statements

Return statements are used to exit functions or procedures, optionally returning a value. Examples include:

return;
return 123;

These statements allow you to exit the current function or procedure. The second return statement additionally returns the value 123.

Block statements

Block statements group multiple statements together within a code block. This aids in organizing code and controlling variable scope. For example:

{
val x = calc();
print(x);
}

Here, a code block is used to encapsulate the assignment of x and the subsequent function call to print.