Search processing.org:

Reference for Processing version 1.0+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name | ### return
Examples |
    int val = 30;

    void draw() {
      int t = timestwo(val);
      println(t);
    }

    int timestwo(int dVal) {
      dVal = dVal * 2;
      return dVal;
    }
    int[] vals = {10, 20, 30};

    void draw() {
      int[] t = timestwo(vals);
      println(t);
      noLoop();
    }

    int[] timestwo(int[] dVals) {
      for(int i = 0; i  dVals.length; i++) {
        dVals[i] = dVals[i] * 2;
      }
      return dVals;
    }
    void draw() {
      background(204);
      line(0, 0, width, height);
      if(mousePressed) {
        return;
      }
      line(0, height, width, 0);
    }
Description | Keyword used to indicate the value to return from a function. The value being returned must be the same datatype as defined in the function declaration. Functions declared with void can't return values and shouldn't include a return value. The keyword return may also be used to break out of a function thus not allowing the program to read the remaining statements (see the third example above).
Syntax |
    type function {
      statements
      return value
    }
Parameters |
type | boolean, byte, char, int, float, String, boolean[], byte[], char[], int[], float[], String[]
function | a function that is being defined
statements | any valid statements
value | must be the same datatype as the type parameter
Usage | Web & Application

Updated on November 22, 2008 08:39:26pm PST