Previous section To contents

3.3.3 return

Return doesn't just exit the loop, it exits the whole function. We have seen several examples how to use it chapter 2. None of the functions in chapter two returned anything in particular however. To do that you just put the return value right after return. Of course the type of the return value must match the type in the function declaration. If your function declaration is int main() the value after return must be an int. For instance, if we wanted to make a program that always returns an error code to the system, just like the UNIX command false this is how it would be done:
#!/usr/local/bin/pike

int main()
{
    return 1;
}
This would return the error code 1 to the system when the program is run.

Previous section To contents