PtokaX forum

Development Section => Your Developing Problems => Topic started by: VidFamne on 01 October, 2004, 01:02:49

Title: return 0 or return nil?
Post by: VidFamne on 01 October, 2004, 01:02:49
As the subject said, whats the diff?
I.e;
function some()
    if something then
    do something
    else
    return 0 --( or return nil)
    end
end
Title:
Post by: Meka][Meka on 01 October, 2004, 01:04:25
return 0

will be returned as (0) nil wil be returned as ()
Title:
Post by: VidFamne on 01 October, 2004, 01:16:50
Yes, I can see that, but is there any difference in how
Ptokax handle this?
You can return 0, 1, -1, and nil
but I havent get a grip on what the difference is, between it.
I'm wondering this because I want to optimize the script
and thought it would be better to return nil instead of return 0. (Saving memory, that is  :D )
Title:
Post by: Meka][Meka on 01 October, 2004, 01:38:02
QuoteOriginally posted by VidFamne
Yes, I can see that, but is there any difference in how
Ptokax handle this?
You can return 0, 1, -1, and nil
but I havent get a grip on what the difference is, between it.
I'm wondering this because I want to optimize the script
and thought it would be better to return nil instead of return 0. (Saving memory, that is  :D )

well return nil is probably better, its what i prefere, u can return anything... not just 0 1 -1, even return "name"

ptokax uses 0 as let, for the rest they are sent to the calling function

edit: nil also i reckon also -1 will all be let numbers, if a functions receives nil, 0 it wont bother returning it will just carry on til it ends... return 1 or other will close the function and return it