blob: 6697cf829a19d81d02a01b3f10d4b97eeff1e867 (
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
|
require_ "rawhash"
function test ()
Tab mytable, another
t = {1,3}
-- Here # is short for #mytable
mytable[#+1] = 1
mytable[#+1] = 2
-- without indexing, behaves just like a table reference
assert(type(mytable)=='table')
-- it is still possible to use #t explicitly
assert(mytable [#]==mytable[#t])
assert(mytable[#-1] == mytable[1])
for i = 1,10 do another[#+1] = i end
for i = 1,10 do assert(another[i] == i) end
end
test()
-- although mytable is a macro, its scope is limited to test()
assert(mytable == nil)
|