# Type Annotations

Unlike any of today’s Lua versions, Lua++ can restrict variables to be of certain type. As projects grow in size, it becomes harder for developers to remember of what type each variable is. Type annotations help prevent insidious bugs that can take hours to discover. In addition, they help enforce interfaces to classes in object-oriented programming.

Lua++ supports five variable primitive types: `boolean`, `string`, `number`, `Table`, and `Array`, which are described in detail in [Broken mention](broken://pages/JRYe5LLCJ1JG5zOfkHNA). To assign a type to a variable, use the `:` separator after the variable name. The annotation can also be used on constant variables. If a variable is assigned a value whose type is not equal to the type of the annotation, then a compiler error will be thrown.

```lua
local a: number = 12
const b: string = "Hello, world!"
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.luaplusplus.org/language-improvements/type-annotations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
