return 0 or return nil?
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

return 0 or return nil?

Started by VidFamne, 01 October, 2004, 01:02:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VidFamne

As the subject said, whats the diff?
I.e;
function some()
    if something then
    do something
    else
    return 0 --( or return nil)
    end
end

Meka][Meka

#1
return 0

will be returned as (0) nil wil be returned as ()
Do you know what \'nemesis\' means? A righteous infliction of retribution manifested by an appropriate agent. Personified in this case by an \'orrible cunt... me.



VidFamne

#2
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 )

Meka][Meka

#3
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
Do you know what \'nemesis\' means? A righteous infliction of retribution manifested by an appropriate agent. Personified in this case by an \'orrible cunt... me.



SMF spam blocked by CleanTalk