generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: TIL null==nil

Previous Thread :: Next Thread 
xIndex is not online. 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 is not online. 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
LegitimatlyMe is not online. LegitimatlyMe
Joined: 30 Oct 2013
Total Posts: 1108
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
Rocketerkid is not online. Rocketerkid
Joined: 10 Oct 2011
Total Posts: 1237
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 is not online. xIndex
Joined: 16 Sep 2015
Total Posts: 31
29 Sep 2015 07:06 PM
That makes sense.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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 is not online. xIndex
Joined: 16 Sep 2015
Total Posts: 31
29 Sep 2015 07:21 PM
So they would!
Report Abuse
cntkillme is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
30 Sep 2015 05:22 PM
@cnt Theoretically you could force it to.

But it would be quite unpractical
Report Abuse
sharpchain1 is not online. sharpchain1
Joined: 05 Aug 2013
Total Posts: 1009
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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Sep 2015 05:37 PM
@warspy *facepalm*
Report Abuse
lordrambo is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
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 is not online. 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 is not online. 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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
30 Sep 2015 06:19 PM
exponentially less efficient as the size increases*
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image