> ## Documentation Index
> Fetch the complete documentation index at: https://requestscript.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Syntax

> Comments, whitespace, identifiers, keywords and literals.

This page covers the building blocks of RequestScript source text: how comments, whitespace, names and literal values are written.

## Comments

A comment starts with `//` and runs to the end of the line. There are no block comments.

```kotlin theme={null}
request Example {
    // This line is ignored
    return 1 // So is everything after the slashes here
}
```

## Whitespace and statements

Whitespace and line breaks don't matter, and statements need no separator. Both of these scripts are valid:

```kotlin theme={null}
request OneLine { var a = 1 var b = 2 return a + b }
```

```kotlin theme={null}
request ManyLines {
    var a = 1
    var b = 2
    return a + b
}
```

> [!WARNING]
>
> `return` is the one exception. The value you return must start on the **same line** as the `return` keyword. If the value starts on the next line, the `return` is treated as a bare `return` and the script returns `null`.
>
> ```kotlin theme={null}
> request Surprise {
>     return
>         5 // never reached: the script returns null
> }
> ```

## Identifiers

Names of variables, object properties, parameters and resources are identifiers. An identifier starts with a letter or underscore, followed by any number of letters, digits or underscores. Identifiers are case-sensitive, so `total` and `Total` are different names.

```kotlin theme={null}
var total = 1
var _count = 2
var item2 = 3
```

## Reserved keywords

These words can't be used as identifiers:

`request` `contract` `var` `const` `return` `if` `else` `true` `false` `null`

Type names such as `int32` and `string` are not reserved.

## Number literals

Numbers are written as decimal digits, optionally with a fractional part:

```kotlin theme={null}
42
3.14
0.5
```

* Write negative numbers with the unary minus operator: `-5`.
* A leading dot isn't allowed: write `0.5`, not `.5`.
* There is no exponent notation (`1e5`), hexadecimal (`0xFF`) or digit separator (`1_000`).

Whole numbers that fit in 32 bits are `int32`, larger whole numbers are `int64`, and numbers with a fractional part are `decimal`. See [Types](/language/types).

## String literals

Strings use double quotes and must fit on a single line.

```kotlin theme={null}
"Hello World!"
```

These escape sequences are supported. Any other backslash sequence is an error.

| Escape | Meaning |
| - | - |
| `\"` | Double quote |
| `\\` | Backslash |
| `\n` | Newline |
| `\t` | Tab |
| `\r` | Carriage return |
| `\$` | Literal dollar sign, to prevent [interpolation](/language/expressions#string-interpolation) |

Strings can embed expressions with `${...}`:

```kotlin theme={null}
"Total: ${price * quantity}"
```

## Other literals

* **Booleans:** `true` and `false`.
* **Null:** `null`.
* **Objects:** `{ name: "Ada", age: 36 }`.
* **Lists:** `[1, 2, 3]`.

Object and list literals are covered in [Expressions](/language/expressions#object-and-list-literals).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.