1619 posts
Posted 07 February 2013 - 06:31 PM
So, lets say I have the following code:
function makeTable(name)
name = {}
end
Wouldn't this create a table named "name"? How would I be able to make a function like this? I see no real use for this, but I'm just curious.
404 posts
Location
St. Petersburg
Posted 07 February 2013 - 06:34 PM
there is no use
i suppose if you were almost out of memory, it would cause an error
because the table's an upvalue (variable in function declaration), it will be garbagecollected every time you call the function
1619 posts
Posted 07 February 2013 - 06:37 PM
there is no use
i suppose if you were almost out of memory, it would cause an error
because the table's an upvalue (variable in function declaration), it will be garbagecollected every time you call the function
Er, doesn't quite answer the question.
2088 posts
Location
South Africa
Posted 07 February 2013 - 06:46 PM
It's easier to type
Tab = {}
…?
404 posts
Location
St. Petersburg
Posted 07 February 2013 - 06:48 PM
all it would do is just ignore what ever was passed to it, create a table, then garbagecollect it
758 posts
Location
Budapest, Hungary
Posted 07 February 2013 - 10:37 PM
function makeTable(name)
_G[name] = {}
end
makeTable("myTable")
print(type(myTable)) -- this'll print "table"
Why not?
1619 posts
Posted 08 February 2013 - 04:11 AM
function makeTable(name)
_G[name] = {}
end
makeTable("myTable")
print(type(myTable)) -- this'll print "table"
Why not?
Thanks for actually answering the question.