return -1;
#2

Returning a value is only relevant if that value is actually used in an assignment or a comparison. Most people tend to use -1 as an invalid value if a valid value that can be returned also includes 0 (e.g. an array index or playerid).

However, it is advised to use INVALID_PLAYER_ID, INVALID_VEHICLE_ID, etc if an invalid value is to be returned. This makes it easier to check and easier to read when viewing that part of the code again several weeks or months later.
Reply


Messages In This Thread
return -1; - by nuriel8833 - 29.02.2012, 14:32
Re: return -1; - by Vince - 29.02.2012, 15:06
Re: return -1; - by nuriel8833 - 29.02.2012, 15:21

Forum Jump:


Users browsing this thread: 1 Guest(s)