23 lines
451 B
Plaintext
23 lines
451 B
Plaintext
T = {}
|
|
T.foo = function()
|
|
return "This is an instance of T"
|
|
end function
|
|
|
|
S = new T
|
|
S.foo = function()
|
|
return "This is an S for sure"
|
|
end function
|
|
|
|
instance = new S
|
|
print "instance.foo: " + instance.foo
|
|
|
|
copy = {}
|
|
copy = copy + instance // copies all elements
|
|
print "copy.foo: " + copy.foo
|
|
|
|
// And to prove this is a copy, and not a reference:
|
|
instance.bar = 1
|
|
copy.bar = 2
|
|
print "instance.bar: " + instance.bar
|
|
print "copy.bar: " + copy.bar
|