> ## 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.

# Types

> The built-in types, null, and how numeric values are promoted.

RequestScript is strictly typed. Every variable, parameter and resource function argument has a type, and values are checked against it.

## Built-in types

| Type | Values | Notes |
| - | - | - |
| `int32` | 32-bit signed integers | Range-checked. Never wraps around. |
| `int64` | 64-bit signed integers | Range-checked. Never wraps around. |
| `decimal` | Exact decimal numbers | `0.1 + 0.2 == 0.3` is `true`. |
| `decimal(p, s)` | Decimals with at most `p` digits before the point and `s` digits after it | Checked whenever a value is stored. |
| `boolean` | `true`, `false` | |
| `string` | Text | |
| `object` | Maps from property names to values | Untyped. Properties can hold values of any type. |
| `[]T` | Lists of `T` | Nestable, for example `[][]int32`. |

## Integers

`int32` holds whole numbers from -2,147,483,648 to 2,147,483,647. `int64` holds whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

Integers never wrap around. A result that doesn't fit in its type is an overflow error:

```kotlin theme={null}
request Overflow {
    var i: int32 = 2147483647
    i = i + 1 // Error: int32 overflow: 2147483648
}
```

See [Operators](/language/operators#arithmetic) for how integer arithmetic chooses its result type.

## Decimals

`decimal` values are exact. They don't suffer from the rounding errors of binary floating-point numbers:

```kotlin theme={null}
request Exact {
    return 0.1 + 0.2 == 0.3 // true
}
```

To limit the size of a decimal, give it a precision with `decimal(p, s)`, where `p` is the maximum number of digits before the decimal point and `s` is the maximum number after it:

```kotlin theme={null}
request Bounded {
    var price: decimal(4, 2) = 1234.56 // OK
    var rate: decimal(1, 2) = 0.125    // Error: more than 2 digits after the decimal point
}
```

The bounds are checked every time a value is stored in the variable or parameter, not just when it's declared. A value that's too large or too precise is an error. It is never rounded or truncated to fit.

## Booleans

`boolean` has exactly two values, `true` and `false`. Conditions in `if` statements and the operands of `!`, `&&` and `||` must be booleans. There is no "truthiness": `if (1)` and `if ("yes")` are errors.

## Strings

`string` holds text. String literals use double quotes and support [escapes and interpolation](/language/syntax#string-literals).

## Objects

An `object` maps property names to values. Objects are untyped: each property can hold a value of any type, including other objects and lists.

```kotlin theme={null}
request Objects {
    var car: object = {
        brand: "Honda",
        year: 2021,
        owner: { name: "Ana" },
    }
    return car.owner.name // "Ana"
}
```

## Lists

`[]T` is a list whose elements are of type `T`. List types nest, so `[][]int32` is a list of lists of integers.

```kotlin theme={null}
request Lists {
    var colors: []string = ["red", "green", "orange"]
    var grid: [][]int32 = [[1, 2], [3, 4]]
    return colors[1] // "green"
}
```

List indexes start at `0`.

## Null

`null` is a value of every type. You can assign it to any variable, pass it as any parameter or store it as any list element:

```kotlin theme={null}
request Nulls {
    var name: string = null
    var counts: []int32 = [1, null, 3]
    return name // null
}
```

## Numeric promotion

A numeric value is automatically promoted when a wider type is expected:

* `int32` is promoted to `int64`.
* `int32` and `int64` are promoted to `decimal`.
* An `int64` value is accepted where `int32` is expected only if it fits in the `int32` range.

```kotlin theme={null}
request Promotion {
    var big: int64 = 5      // int32 literal promoted to int64
    var amount: decimal = 5 // int32 literal promoted to decimal
    return amount
}
```

No other implicit conversions exist. In particular, a string is never converted to a number, and a number is never converted to a boolean:

```kotlin theme={null}
request NoConversion {
    var s: string = 5 // Error: Cannot use a int32 value as string
}
```

The one place values are turned into strings is string concatenation and interpolation. See [Operators](/language/operators#string-concatenation).


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