This commit is contained in:
William Bell committed 2023-03-31 20:45:59 +01:00
1 parent bd58748eaa
commit 5c12756d58
2 files changed
+6 -2

No files matched your search

+3 -1
View File
@@ -1,2 +1,4 @@
# docs # docs
read the [spec](spec) read the [spec](spec)
- [Variable and function assignment](variable-and-function-assignment)
@@ -9,7 +9,7 @@ To define a variable using the `let` keyword, you need to specify the variable n
let x = 10 let x = 10
``` ```
In this example, we define a variable named `x` and initialise it with a value of `10`. The `let` keyword tells the Argon interpreter to define the variable on the current stack. In this example, we define a variable named `x` and initialise it with a value of `10`. The `let` keyword tells the Argon interpreter to define the variable on the current stack. If `x` already exists in the current stack, then it will throw a `Name Error` of `Name Error: variable "x" already exists`.
Method 2: Assigning a value to a variable name Method 2: Assigning a value to a variable name
@@ -49,6 +49,8 @@ In this example, we define a variable `x` with a value of `10` using `let`. We t
# Function Assignment # Function Assignment
`let` works exactly the same way as it does in variable assignment.
```javascript ```javascript
let square(x) = do let square(x) = do
return x * x return x * x