@@ -14,20 +14,30 @@ The package supports:
14
14
* ** booleans** - ` true ` and ` false `
15
15
* ** nil** - ` nil `
16
16
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
+
17
27
## Accessing Public Properties
18
28
19
29
Public properties on structs can be accessed by using the ` . ` syntax.
20
30
If you pass an array into an expression, use the ` [] ` syntax to access array keys.
21
31
22
- ``` coffeescript
32
+ ``` js
23
33
foo .Array [0 ].Value
24
34
```
25
35
26
- ## Calling Methods
36
+ ## Functions and Methods
27
37
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.
29
39
30
- ``` coffeescript
40
+ ``` js
31
41
price .String ()
32
42
```
33
43
@@ -46,20 +56,10 @@ The package comes with a lot of operators:
46
56
47
57
Example:
48
58
49
- ``` coffeescript
59
+ ``` js
50
60
life + universe + everything
51
61
```
52
62
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
-
63
63
### Comparison Operators
64
64
65
65
* ` == ` (equal)
@@ -91,15 +91,15 @@ life < universe || life < everything
91
91
92
92
To test if a string does * not* match a regex, use the logical ` not ` operator in combination with the ` matches ` operator:
93
93
94
- ``` coffeescript
94
+ ``` js
95
95
not (" foo" matches " ^b.+" )
96
96
```
97
97
98
98
You must use parenthesis because the unary operator ` not ` has precedence over the binary operator ` matches ` .
99
99
100
100
Example:
101
101
102
- ``` coffeescript
102
+ ``` js
103
103
' Arthur' + ' ' + ' Dent'
104
104
```
105
105
@@ -112,11 +112,11 @@ Result will be set to `Arthur Dent`.
112
112
113
113
Example:
114
114
115
- ``` coffeescript
115
+ ``` js
116
116
user .Group in [" human_resources" , " marketing" ]
117
117
```
118
118
119
- ``` coffeescript
119
+ ``` js
120
120
" foo" in {foo: 1 , bar: 2 }
121
121
```
122
122
@@ -126,13 +126,13 @@ user.Group in ["human_resources", "marketing"]
126
126
127
127
Example:
128
128
129
- ``` coffeescript
129
+ ``` js
130
130
user .Age in 18..45
131
131
```
132
132
133
133
The range is inclusive:
134
134
135
- ``` coffeescript
135
+ ``` js
136
136
1..3 == [1 , 2 , 3 ]
137
137
```
138
138
@@ -142,7 +142,7 @@ The range is inclusive:
142
142
143
143
Example:
144
144
145
- ``` coffeescript
145
+ ``` js
146
146
user .Age > 30 ? " mature" : " immature"
147
147
```
148
148
@@ -159,9 +159,10 @@ user.Age > 30 ? "mature" : "immature"
159
159
160
160
Example:
161
161
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 })
165
166
```
166
167
167
168
## Closures
@@ -170,14 +171,14 @@ all(Tweets, {.Size < 140})
170
171
171
172
Closures allowed only with builtin functions. To access current item use ` # ` symbol.
172
173
173
- ``` go
174
- map (0 ..9 , {# + 1 })
174
+ ``` js
175
+ map (0..9 , {# / 2 })
175
176
```
176
177
177
178
If the item of array is struct, it's possible to access fields of struct with omitted ` # ` symbol (` #.Value ` becomes ` .Value ` ).
178
179
179
- ``` go
180
- filter (Tweets, {. Size > 140 })
180
+ ``` js
181
+ filter (Tweets, {len (. Value ) > 280 })
181
182
```
182
183
183
184
## Slices
@@ -188,8 +189,9 @@ Slices can work with arrays or strings.
188
189
189
190
Example:
190
191
191
- ``` go
192
- // array is [1,2,3,4,5]
192
+ Variable ` array ` is ` [1,2,3,4,5] ` .
193
+
194
+ ``` js
193
195
array[1 : 5 ] == [2 ,3 ,4 ]
194
196
array[3 : ] == [4 ,5 ]
195
197
array[: 4 ] == [1 ,2 ,3 ]
0 commit comments