Results 1 to 3 of 3
Thread: [Lua] ~= nil
10-27-2013, 02:59 PM #1
- Join Date
- May 2011
- Where the Green Grass Grows. <3
[Lua] ~= nil
if obj ~= nil and obj.type ~= nil
So.... nil represents wut.
Edit: From what I've been seeing, the output of nil is like an error - a value that just doesn't exist... kind of. But I still don't understand why the statement in one of these scripts I'm looking at would check to see if the object and obj.type were nil. Would it be checking to see if the object doesn't exist?
Last edited by Austin .; 10-27-2013 at 03:17 PM.
10-27-2013, 03:42 PM #2
- Join Date
- Feb 2013
nil basically represents none. you can send messages to nil, and use it just about anywhere you can as null.
10-27-2013, 04:35 PM #3
Nil and null essentially mean the value doesn't exist. So, by checking if something equals nil, you're checking if any value exists for it or not. It's not checking whether the object exists, because clearly it does or you couldn't use it in a statement like that. It's checking the value of that object.
Some context for whatever code you're talking about would be nice; may be able to tell you exactly why.