[ create a new paste ] login | about

Link: http://codepad.org/e52KGRhA    [ raw code | output | fork ]

Programming-Idioms - Lua, pasted on Jun 24:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
local x = setmetatable({},{
	__index = function(t,k)
		t[k] = setmetatable({},{
			__index = function(t,k)
				t[k] = 0
				return t[k]
			end
		})
		return t[k]
	end
})

x[4][2] = 42
print("[4][2] : "..x[4][2])
print("[0][0] : "..x[0][0])
print("[10000000][154132148] : "..x[10000000][154132148])


Output:
1
2
3
[4][2] : 42
[0][0] : 0
[10000000][154132148] : 0


Create a new paste based on this one


Comments: