A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://docs.leaflabs.com/static.leaflabs.com/pub/leaflabs/maple-docs/latest/lang/cpp/return.html below:

return — Maple v0.0.12 Documentation

return¶

Terminates a function and return a value from a function to the calling function, if the function has non-void return type.

Syntax:¶
// from within a "void" function:
return;

// from within a non-"void" function:
return value;

In the second case, value should have a type which is the same as the return type of the function, or be convertible to it (like an int to a double, etc.; see this note for some references).

Examples:¶

A function to compare a sensor input to a threshold:

 // converts analog readings between 0 and 400 to 0, and 400 up to 1.
 int checkSensor() {
    if (analogRead(0) > 400) {
        return 1;
    else {
        return 0;
    }
}

An early return is also useful when testing a section of code without having to “comment out” large sections of possibly buggy code, like so:

void loop() {

    // brilliant code idea to test here

    return;

    // the rest of a dysfunctional sketch here
    // this code will never be executed
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4