This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Vala Value Sample

void main () {
    Value v;  // a GLib.Value

    v = 5;  // an integer auto-boxed into a Value
    print ("value: %d\n", (int) v);  // unboxing via cast

    // reset to its default value
    v.reset ();
    print ("value: %d\n", (int) v);  // unboxing via cast

    v = "hello";  // a string auto-boxed into a Value
    print ("value: %s\n", (string) v);  // unboxing via cast
}

Compile and Run

$ valac valuesample.vala
$ ./valuesample


Vala/Examples


2024-10-23 11:37