1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
do
{a, b} = hello
{{a}, b, {c}} = hello
{ :hello, :world } = value
do
x, [a, b] = f!
print x, a, b
do
list = [ [1, 2], [3, 4]]
{x, y}, list = lume.first(list), lume.slice list, 2
do
{ yes: no, thing } = world
{:a,:b,:c,:d} = yeah
{a}, b = one, two
{b}, c = one, nil
{d}, e = one, two
x, {y} = one, two
xx, yy = 1, 2
{yy, xx} = {xx, yy}
{a, :b, c, :d, e, :f, g} = tbl
do :a, :b, c = tbl, nil
do a, :b, :c = tbl, _
do :a, b, :c = tbl, _, _
---
do
futurists =
sculptor: "Umberto Boccioni"
painter: "Vladimir Burliuk"
poet:
name: "F.T. Marinetti"
address: {
"Via Roma 42R"
"Bellagio, Italy 22021"
}
do {poet: {:name, address: {street, city}}} = futurists
do {
:sculptor
:painter
poet:
:name
address:
* street
* city
} = futurists
do
a:
b: c
d: e = tb
do
a:
* b: c
* d: e
* f = tb
--
do
{ @world } = x
{ a.b, c.y, func!.z } = x
{ world: @world } = x
--
do
thing = {{1,2}, {3,4}}
for {x,y} in *thing
print x,y
for [x,y] in *thing
print x,y
--
do
with {a,b} := thing
print a, b
--
do
thing = nil
if {a} := thing
print a
else
print "nothing"
thang = {1,2}
if {a,b} := thang
print a,b
if {a,b} := thing
print a,b
elseif {c,d} := thang
print c,d
else
print "NO"
--
do
z = "yeah"
{a,b,c} = z
do
{a,b,c} = z
_ = (z) ->
{a,b,c} = z
do
z = "oo"
_ = (k) ->
{a,b,c} = z
do
{function:{end:endVar}} = thing
do
{if:{a,b,c}} = thing
do
{:a, :b} = {a: "Hello", b: "World"} if true
{days, hours, mins, secs} = [tonumber a for a in *{
string.match "1 2 3 4", "(.+)%s(.+)%s(.+)%s(.+)"
}]
{:one, :two, :three} = {w,true for w in foo\gmatch("%S+")}
{:a},b = a\if(123) + t, 123
do
{:name = "nameless", :job = "jobless"} = person
request = (url, options = {}) ->
{
:method = "GET"
:headers = {}
:parameters = {}
:payload = ""
:ok
:err
:final
} = options
res = makeRequest(url, method, parameters, payload, ok, err, final)
return res
{key1: {key2: value1 = 123}, :key3 = "abc"} = tb
{<>: mt = {__index: {abc: 123}}, <>: {:<call> = (-> {}), :<add>}} = tb
{x: {<>: mtx = {}}, :y, z: zItem, :<index> = -> nil} = tb
{<>: {func: a.b(-> 123).c = item?.defVal}} = tb
do
{<>: mt = {}, <sub>: subFunc} = tb.x
do
{x: {<>: mt = {}, <sub>: subFunc}} = tb
do
{a = 1, b = 2, c: {d.e = 3}} = tb
for {left = "null", right = false} in *tuples
print left, right
for [left = "null", right = false] in *tuples
print left, right
do
{_, a, _, b} = tb -- list placeholder
do
[a, _, b, _] = tb -- list placeholder
do
{x: a.b = 1, y: a.c = 2} = x.x.x
do
const :width, :height = View.size
const {:x = 0.0, :y = 0.0} = point
do
x1, x2, x3, a[], d, {b}, e, c.<> = 1, 2, 3, f!
y1, :y2, :y3, y4 = f1!, f2!
do
{
[["abc"]]: v1 = 111,
[1 + 1]: {v2 = 222, v3 = 333},
@x: v4 = 444
}, \
'x-y-z': v5, [func!]: {[func2!]: v6, v7} = tb, tb2
do
<[name]>: value_meta, [name]: value = tb
do
{:<tostring> = (-> "name"), :<add>} = tb
switch tb
when {:<name> = "item", <"123">: meta_field}
print name, meta_field
do
tb = {}
<[a + b]>: v1, [c!]: v2 = tb
do
{a: {:<add> = addFunc}, b: {<[fieldName]>: field = 123}} = tb
{<"abc">: meta_field = "def", <[[any string]]>: abc = 123, <'str'>: def = {}} = tb
switch tb
when {a: {:<add> = addFunc}, b: {<[fieldName]>: field = 123}}
print add, field
switch tb
when {c: {<"abc">: meta_field = "def"}, <[[any string]]>: {d: abc = 123}, <'str'>: {e: def = {}}}
print meta_field, abc, def
do
clients = ["VIP_Alice", "User_Bob", "User_Clara", "VIP_Eva"]
[vipStart, ...regulars, vipEnd] = clients
print vipStart -- "VIP_Alice"
print regulars -- {"User_Bob", "User_Clara"}
print vipEnd -- "VIP_Eva"
do
setupMeeting = (participants) ->
[chair, ..._, secretary] = participants
print chair, secretary
setupMeeting ["Alice", "Bob", "Charlie", "David"]
-- Output: Alice David
do
getTransactions = ->
{
{id: "T1", amount: 100}
{id: "T2", amount: 200}
{id: "T3", amount: 300}
}
:id, :amount = getTransactions![#]
assert id == "T3"
assert amount == 300
do
[
_
...middle
_
] = tb
do
{a, :abc, b, :def, ...sub, d, e} = tb
nil
|