Skip to content

Commit cce2c7a

Browse files
committed
docs: add info
1 parent 566e584 commit cce2c7a

2 files changed

Lines changed: 45 additions & 11 deletions

File tree

docs/versions/v3/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Textwire operates similarly to Go when it comes to mathematical expressions. You
7171
- Logical OR: `||` (`a || b`)
7272

7373
:::warning Type Mismatching
74-
Type mismatching is not supported when performing mathematical operations. For example, you cannot add an integer to a float directly. Type conversion is required to match types using conversion functions such as `<your float>.int()`, `<your int>.float()`, etc.
74+
Type mismatching is not supported when performing mathematical operations. For example, you cannot add an integer to a float directly. Type conversion is required to match types using conversion functions such as `{{ 3 * 2.3.int() }}`, `{{ 3.3 + 2.float() }}`, etc.
7575
:::
7676

7777
## Reserved Variable Names

docs/versions/v3/language-elements/expressions.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,36 @@ You can use infix expressions to perform arithmetic operations. Example:
4343
<li>{{ x * y }}</li> {{-- Multiplication --}}
4444
<li>{{ x / y }}</li> {{-- Division --}}
4545
<li>{{ x % y }}</li> {{-- Modulo --}}
46+
<li>{{ x == y }}</li> {{-- Equality --}}
47+
<li>{{ x != y }}</li> {{-- Inequality --}}
48+
<li>{{ x && y }}</li> {{-- Logical AND --}}
49+
<li>{{ x || y }}</li> {{-- Logical OR --}}
4650
<li>{{ (x + 2) / (y * (4 - c)) }}</li> {{-- Grouped expressions --}}
4751
</ul>
4852
```
4953

54+
### Infix Operators
55+
56+
| Operator | Description | Left/Right types |
57+
| -------- | ---------------- | ---------------------------- |
58+
| `==` | Equal | `any` |
59+
| `!=` | Not equal | `any` |
60+
| `&&` | Logical AND | `any` |
61+
| `\|\|` | Logical OR | `any` |
62+
| `%` | Modulo | `integer` |
63+
| `+` | Plus | `integer`, `float`, `string` |
64+
| `-` | Minus | `integer`, `float` |
65+
| `*` | Multiply | `integer`, `float` |
66+
| `/` | Divide | `integer`, `float` |
67+
| `>` | Greater | `integer`, `float` |
68+
| `<` | Less | `integer`, `float` |
69+
| `>=` | Greater or equal | `integer`, `float` |
70+
| `<=` | Less or equal | `integer`, `float` |
71+
72+
### Important Notes
73+
74+
- **String concatenation.** Use `+` operator to concatenate strings. Example: <code v-pre>{{ "Hello, " + name }}</code> will result in `Hello, {name}`.
75+
5076
## Postfix
5177

5278
You can use postfix expressions to increment or decrement a variable. Example:
@@ -56,6 +82,13 @@ You can use postfix expressions to increment or decrement a variable. Example:
5682
<span>{{ x-- }}</span> {{-- Decrement --}}
5783
```
5884

85+
### Postrix Operators
86+
87+
| Operator | Description | Left/Right types |
88+
| -------- | ----------- | ------------------ |
89+
| `++` | Increment | `integer`, `float` |
90+
| `--` | Decrement | `integer`, `float` |
91+
5992
## Comparison
6093

6194
Comparison expressions produce a boolean value. Example:
@@ -66,18 +99,19 @@ Comparison expressions produce a boolean value. Example:
6699
@end
67100
```
68101

69-
### Supported Operators
102+
### Comparison Operators
70103

71-
All supported operators are listed in the table below:
104+
| Operator | Description | Left/Right types |
105+
| -------- | ---------------- | ------------------ |
106+
| `==` | Equal | `any` |
107+
| `!=` | Not equal | `any` |
108+
| `>` | Greater | `integer`, `float` |
109+
| `<` | Less | `integer`, `float` |
110+
| `>=` | Greater or equal | `integer`, `float` |
111+
| `<=` | Less or equal | `integer`, `float` |
72112

73-
| Operator | Description |
74-
| -------- | ---------------- |
75-
| `==` | Equal |
76-
| `!=` | Not equal |
77-
| `>` | Greater |
78-
| `<` | Less |
79-
| `>=` | Greater or equal |
80-
| `<=` | Less or equal |
113+
- **Any type for equality operators.** Unlike Go, in Textwire, operators `==`, `!=`, `&&` and `||` can be used with any types on left and right.
114+
- **Compare arrays and objects.** Use `==` and `!=` to deeply compare arrays and objects. Example: <code v-pre>{{ [1, 2] == [1, 2] }}</code> will result in `true` because both arrays have the same elements in the same order. Similarly, <code v-pre>{{ { name: "Chiori" } == { name: "Chiori" } }}</code> will also result in `true` because both objects have the same key-value pairs. It works for deeply nested arrays and objects as well.
81115

82116
## Function Calls
83117

0 commit comments

Comments
 (0)