Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Polymorphic-copy/MiniScript/polymorphic-copy.mini
Normal file
22
Task/Polymorphic-copy/MiniScript/polymorphic-copy.mini
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue