Skip to main content
Skip to content

Variables keyword

rakho — let (declare a variable)

rakho creates a new variable and optionally gives it a starting value. The value can be changed later with a plain =.

Meaning: "keep" — keep this value under a name

How rakho works

Write rakho, a name, = and a value. The name must start with a letter or underscore and may contain letters, digits and underscores. Leave the value out (rakho jawab;) and the variable starts as khali.

Variables are block-scoped: one created inside { } disappears when the block ends, while code inside a block can still read and update variables declared outside it. A variable can hold any type and may switch type later.

Use rakho once per name per block. After that, update the value with naam = naya_value;.

Syntax

syntax
rakho naam = value;
rakho khaali_variable;

Runnable example

Expected output

Press Run to try it

Jaipur mein 30 lakh log rehte hainAb: 31

Same idea in JavaScript and Python

JavaScript
let shehar = "Jaipur";
let log = 30;
console.log(shehar, "mein", log, "lakh log rehte hain");
log = log + 1;
Python
shehar = "Jaipur"
log = 30
print(shehar, "mein", log, "lakh log rehte hain")
log = log + 1

Common mistakes

Declaring the same name twice

A second rakho for a name that already exists in the same block stops the program with an "already declared" error. Drop rakho when you only want to change the value.

Galat
rakho score = 10;
rakho score = 20;
Sahi
rakho score = 10;
score = 20;
bol(score);

Assigning before declaring

total = 5; without an earlier rakho total is an error, because there is no box called total yet. Declare it first.

Galat
total = 5;
Sahi
rakho total = 5;
bol(total);

rakho: frequently asked questions

Is rakho like let or var in JavaScript?

It behaves like let: the variable belongs to the block it was declared in, and it can be reassigned. Declaring the same name twice in one block is an error.

Can a rakho variable change its type?

Yes. AltFLang is dynamically typed, so a variable that held a number can later hold text, a list or khali. Use prakar() to check what it holds right now.