The new syntax is pretty simple, and works for strings too:
Code: Select all
t = {"a", "b", "c", "d"}
print(#t) --> 4
s = "abc"
print(#s) --> 3
Code: Select all
t = {"a", "b", "c", "d"}
print(#t) --> 4
s = "abc"
print(#s) --> 3
Doesn't seem to work in 0.5.0 (Yes, I'm still using it. I haven't had the time to screw around and get it working in 0.6.0 yet.). Is it a new feature of Lua that only 0.6.0 has installed?bartbes wrote:It might be removed in the future, or rather, it will be.
The new syntax is pretty simple, and works for strings too:Code: Select all
t = {"a", "b", "c", "d"} print(#t) --> 4 s = "abc" print(#s) --> 3
But does it still remove the row from memory? Or at least from view of the program as if it doesn't exist anymore? Since I can't use table.remove anymore with the method I need to use, I need an equivalent. And setting it to nil seems to work.Robin wrote:Note that "setting something to nil" doesn't destroy it, it just lowers the reference count by 1, if the rc reaches 0 the object is destroyed.
That should work. I'm not sure what is going on, but 0.5.0 uses Lua 5.1.Jasoco wrote:Doesn't seem to work in 0.5.0 (Yes, I'm still using it. I haven't had the time to screw around and get it working in 0.6.0 yet.). Is it a new feature of Lua that only 0.6.0 has installed?bartbes wrote:It might be removed in the future, or rather, it will be.
The new syntax is pretty simple, and works for strings too:Code: Select all
t = {"a", "b", "c", "d"} print(#t) --> 4 s = "abc" print(#s) --> 3
Well, it does if there is only one reference. Example:Jasoco wrote:But does it still remove the row from memory? Or at least from view of the program as if it doesn't exist anymore? Since I can't use table.remove anymore with the method I need to use, I need an equivalent. And setting it to nil seems to work.
Code: Select all
sometable = {'hello'}
otherref = sometable
sometable = nil
print(otherref[1]) --prints hello
Users browsing this forum: Ahrefs [Bot] and 9 guests