Skip to content

Commit eb09e1d

Browse files
authored
Update Language-Definition.md
1 parent e027ff6 commit eb09e1d

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

docs/Language-Definition.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,30 @@ The package supports:
1414
* **booleans** - `true` and `false`
1515
* **nil** - `nil`
1616

17+
## Digit separators
18+
19+
Integer literals may contain digit separators to allow digit grouping into more legible forms.
20+
21+
Example:
22+
23+
```
24+
10_000_000_000
25+
```
26+
1727
## Accessing Public Properties
1828

1929
Public properties on structs can be accessed by using the `.` syntax.
2030
If you pass an array into an expression, use the `[]` syntax to access array keys.
2131

22-
```coffeescript
32+
```js
2333
foo.Array[0].Value
2434
```
2535

26-
## Calling Methods
36+
## Functions and Methods
2737

28-
The `.` syntax can also be used to call methods on an struct.
38+
Functions may be called using `()` syntax. The `.` syntax can also be used to call methods on an struct.
2939

30-
```coffeescript
40+
```js
3141
price.String()
3242
```
3343

@@ -46,20 +56,10 @@ The package comes with a lot of operators:
4656

4757
Example:
4858

49-
```coffeescript
59+
```js
5060
life + universe + everything
5161
```
5262

53-
### Digit separators
54-
55-
Integer literals may contain digit separators to allow digit grouping into more legible forms.
56-
57-
Example:
58-
59-
```
60-
10_000_000_000
61-
```
62-
6363
### Comparison Operators
6464

6565
* `==` (equal)
@@ -91,15 +91,15 @@ life < universe || life < everything
9191

9292
To test if a string does *not* match a regex, use the logical `not` operator in combination with the `matches` operator:
9393

94-
```coffeescript
94+
```js
9595
not ("foo" matches "^b.+")
9696
```
9797

9898
You must use parenthesis because the unary operator `not` has precedence over the binary operator `matches`.
9999

100100
Example:
101101

102-
```coffeescript
102+
```js
103103
'Arthur' + ' ' + 'Dent'
104104
```
105105

@@ -112,11 +112,11 @@ Result will be set to `Arthur Dent`.
112112

113113
Example:
114114

115-
```coffeescript
115+
```js
116116
user.Group in ["human_resources", "marketing"]
117117
```
118118

119-
```coffeescript
119+
```js
120120
"foo" in {foo: 1, bar: 2}
121121
```
122122

@@ -126,13 +126,13 @@ user.Group in ["human_resources", "marketing"]
126126

127127
Example:
128128

129-
```coffeescript
129+
```js
130130
user.Age in 18..45
131131
```
132132

133133
The range is inclusive:
134134

135-
```coffeescript
135+
```js
136136
1..3 == [1, 2, 3]
137137
```
138138

@@ -142,7 +142,7 @@ The range is inclusive:
142142

143143
Example:
144144

145-
```coffeescript
145+
```js
146146
user.Age > 30 ? "mature" : "immature"
147147
```
148148

@@ -159,9 +159,10 @@ user.Age > 30 ? "mature" : "immature"
159159

160160
Example:
161161

162-
```go
163-
// Ensure all tweets are less than 140 chars.
164-
all(Tweets, {.Size < 140})
162+
Ensure all tweets are less than 280 chars.
163+
164+
```js
165+
all(Tweets, {.Size < 280})
165166
```
166167

167168
## Closures
@@ -170,14 +171,14 @@ all(Tweets, {.Size < 140})
170171

171172
Closures allowed only with builtin functions. To access current item use `#` symbol.
172173

173-
```go
174-
map(0..9, {# + 1})
174+
```js
175+
map(0..9, {# / 2})
175176
```
176177

177178
If the item of array is struct, it's possible to access fields of struct with omitted `#` symbol (`#.Value` becomes `.Value`).
178179

179-
```go
180-
filter(Tweets, {.Size > 140})
180+
```js
181+
filter(Tweets, {len(.Value) > 280})
181182
```
182183

183184
## Slices
@@ -188,8 +189,9 @@ Slices can work with arrays or strings.
188189

189190
Example:
190191

191-
```go
192-
// array is [1,2,3,4,5]
192+
Variable `array` is `[1,2,3,4,5]`.
193+
194+
```js
193195
array[1:5] == [2,3,4]
194196
array[3:] == [4,5]
195197
array[:4] == [1,2,3]

0 commit comments

Comments
 (0)