Variable
Variable
Function
variable is used to name the value for subsequent reading, modification and transfer. BT is a dynamically typed language, and variables can be reassigned to different types of values during runtime.
Syntax
name = 'Nina' age = 26 sex = 'Girl'
Naming rules
| Rules | Description |
|---|---|
| The first character | can be lowercase English letters, _ or $, and cannot be numbers or uppercase letters. |
| The following characters | can be English letters, numbers, _ or $. |
| Case | Case-sensitive, name and Name have different meanings. |
Names matching [A-Z][A-Za-z0-9_]* will be recognized as constants, such as Name, Config, NAME, Name_1. If the first letter is capitalized but contains $, such as User$, an error will be reported directly.
let local declaration
let is used to declare local variables within the current function. The uninitialized variable value is empty. let is only a variable and cannot be used to declare constants.
fn demo() { let count = 1 count++ count }
Return Value
| Type | Description |
|---|---|
| Any | Assignment expression returns the value of the expression on the right. |
Code Examples
data = 'Nina' data = 26 data = true first second third println data println is_empty(first)
Notes
- Multiple statements can be written on new lines or separated by commas.
-
first second thirdThis null declaration initializes the variable toempty.