2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
title: let
|
|
|
|
layout: command
|
2022-03-04 13:10:09 +01:00
|
|
|
version: 0.59.1
|
2022-02-14 03:22:51 +01:00
|
|
|
---
|
|
|
|
|
2021-05-30 02:57:04 +02:00
|
|
|
Create a variable and give it a value.
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
## Signature
|
|
|
|
|
|
|
|
```> let (var_name) (initial_value)```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
- `var_name`: variable name
|
|
|
|
- `initial_value`: equals sign followed by value
|
2021-05-30 02:57:04 +02:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Set a variable to a value
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> let x = 10
|
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-14 03:22:51 +01:00
|
|
|
Set a variable to the result of an expression
|
2021-05-30 02:57:04 +02:00
|
|
|
```shell
|
2022-02-14 03:22:51 +01:00
|
|
|
> let x = 10 + 100
|
|
|
|
```
|
2021-05-30 02:57:04 +02:00
|
|
|
|
2022-02-20 02:13:33 +01:00
|
|
|
Set a variable based on the condition
|
|
|
|
```shell
|
2022-03-03 01:55:03 +01:00
|
|
|
> let x = if false { -1 } else { 1 }
|
2022-02-20 02:13:33 +01:00
|
|
|
```
|