aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/destructure.mp
blob: 49e639365c041d26471227376891ad661cc81414 (plain)
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

do
	{a, b} = hello

	{{a}, b, {c}} = hello

	{ :hello, :world } = value

do
	{ yes: no, thing } = world

	{:a,:b,:c,:d} = yeah

	{a} = one, two
	{b}, c = one
	{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
	futurists =
		sculptor: "Umberto Boccioni"
		painter:	"Vladimir Burliuk"
		poet:
			name:	 "F.T. Marinetti"
			address: {
				"Via Roma 42R"
				"Bellagio, Italy 22021"
			}

	{poet: {:name, address: {street, city}}} = futurists

--

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


--

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