CAST 1g 2023-08-07 laplante@plcb.ca GOWEB/Language


title: “CAST” author: “laplante@plcb.ca” date: 2023-08-07 version: “1.0.0”

category: “GOWEB/Language”

Description

Cast functions are used to transform a value from one type into another.
GoWeb provides five casting functions:

These casts are useful for explicit type conversion, ensuring correct behavior when working across mixed types.

Examples

res={{
    i := 1;
    string(i);
    bool(i);
    float(i);
    cast::int(i);

    "-";

    i := 0;
    string(i);
    bool(i);
    float(i);
    cast::int(i);

    "-";

    i := 1.1;
    string(i);
    bool(i);
    float(i);
    cast::int(i);

    "-";

    i := 0.0;
    string(i);
    bool(i);
    float(i);
    cast::int(i);

    "-";

    i := true;
    string(i);
    bool(i);
    float(i);
    cast::int(i);

    "-";

    i := false;
    string(i);
    bool(i);
    float(i);
    cast::int(i);
}}.

return 

res=1true11-0false00-1.1true1.11-0false00-true11-false00.

Author

laplante@plcb.ca

See also

Version