xIndex
|
  |
| Joined: 16 Sep 2015 |
| Total Posts: 31 |
|
|
| 29 Sep 2015 06:50 PM |
local t= null ;if t == nil then print("t is nil") end Run that in cmdbar |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 29 Sep 2015 06:52 PM |
I'm so scared to try this, even though I think it's harmless. The only thing I find suspicious is null, but I doubt that's anything............ |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2015 06:53 PM |
| the way you defined "null" makes it nil, you didn't make it a string, or anything, and null was never defined, making it nil. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2015 06:53 PM |
| Nil is meant to represent an object, Null is like numbers. So. I think Null wouldn't be nil. Unless Nil also represented a number? I dunno. |
|
|
| Report Abuse |
|
|
xIndex
|
  |
| Joined: 16 Sep 2015 |
| Total Posts: 31 |
|
| |
|
|
| 29 Sep 2015 07:06 PM |
nil means nothing. Absolutely nothing. null also means this, except the term in Lua is known as 'nil'.
If you want proof of this run this in commandbar:
local x = Instance.new("Part", workspace) x:Destroy() x.Parent = workspace
It should result in some sort of warning, which says that the current parent is null.
Why does the code in the original post work? Because like it said, null is nil. Null has no assigned value, and the script itself doesn't give it one. Meaning the variable null is, equivalently, nil.
H4xxy. |
|
|
| Report Abuse |
|
|
xIndex
|
  |
| Joined: 16 Sep 2015 |
| Total Posts: 31 |
|
|
| 29 Sep 2015 07:17 PM |
Lets consider this table tab = {a = null,b=null,c=null} would a,b and c all be removed from the table? |
|
|
| Report Abuse |
|
|
xIndex
|
  |
| Joined: 16 Sep 2015 |
| Total Posts: 31 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 29 Sep 2015 07:34 PM |
| I doubt it would resize, IIRC Lua tables only resize to become bigger, never smaller. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 05:22 PM |
@cnt Theoretically you could force it to.
But it would be quite unpractical |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 05:29 PM |
| Nil means absolutely nothing Null means the same thing roblox just uses nil instead of null other programming languages like C++ uses null |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 30 Sep 2015 05:38 PM |
| warspyking stop, you don't know what you're talking about |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 06:08 PM |
lordrambo stop, I know exactly what I'm talking about:
tab = {} vals = 10000000 for i = 1, vals do tab[i] = i end print(collectgarbage("count")) for i = 1, vals do tab[i] = nil end print(collectgarbage("count")) for i = vals + 1, 2*vals do tab[i] = nil end print(collectgarbage("count"))
*technically* this works. However as previously stated, highly unpractical. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 06:10 PM |
I'm confused, doesn't lua automatically clean up nil keys and values from a table?
morashsPeasant is flipping |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Sep 2015 06:12 PM |
| LMFAO you literally copied that from the PDF and you give no credit nor do you understand what it's actually doing. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 30 Sep 2015 06:15 PM |
| I doubt you know "exactly" what your talking about (especially considering you just copy and pasted someone else's conclusion, not your own) and yes, that is very "unpractical" |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Sep 2015 06:17 PM |
| Forcing a rehash is not a good solution, sure it will force resize the table but the drawbacks are phenomenal, and gets exponentially less efficient. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Sep 2015 06:19 PM |
| exponentially less efficient as the size increases* |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 06:19 PM |
| ^ As I said unpractical. As for copy-pasting without credit, it isn't copy-pasted, the script is hugely different and the only similarity is I used the same math because I cbb to work it out myself, I have stuff to do too y'know. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Sep 2015 06:22 PM |
You're a dumb skid who steals scripts to try and look smart when in reality you're a damn idiot who should get out.
http://www.lua.org/gems/sample.pdf |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 30 Sep 2015 06:26 PM |
you changed one variable name and added some whitespace
going to go on a limb here and say that the only reason you found the pdf to bein with was because you decided to fact check cntkillme via google and that popped up AND now you're going to harass people on the forums so it looks like you know what you're talking about (like you do all the time) |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 06:27 PM |
cnt, please don't even start. Have you ever heard the phrase 'don't reinvent the wheel'?
Well I didn't want to re'trial-and-error' the math.
It's literally the same as if I looked up the equation to get the area of a circle. I know there's a way; I've done it before, I just don't want to work it out.
Is that so difficult to understand? |
|
|
| Report Abuse |
|
|
Aexura
|
  |
| Joined: 06 Aug 2015 |
| Total Posts: 265 |
|
|
| 30 Sep 2015 06:27 PM |
Page 7 - http://www.lua.org/gems/sample.pdf
a = {} lim = 10000000 for i = 1, lim do a[i] = i end -- create a huge table print(collectgarbage("count")) --> 196626 for i = 1, lim do a[i] = nil end -- erase all its elements print(collectgarbage("count")) --> 196626 for i = lim + 1, 2*lim do a[i] = nil end -- create many nil elements print(collectgarbage("count")) --> 17
Hmm. I saw something just like this somewhere just 5 minutes ago... |
|
|
| Report Abuse |
|
|
rayk999
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 30 Sep 2015 06:27 PM |
wow cnt and lordrambo are really bringing it onto warspyking
Red Blossoms |
|
|
| Report Abuse |
|
|