Does vala have a static variable function?

Does Vala have static variable functions?

"Static variable of type" means a variable declared inside a function that retains its value between calls, for example, in the following example:

#include <stdio.h>

void foo()
{
    int a = 10;
    static int sa = 10;

    a += 5;
    sa += 5;

    printf("a = %d, sa = %d\n", a, sa);
}

      

+3


source to share


1 answer


No, it is not.

In your example, you can either use a global variable or wrap the function in a class and make the variable an attribute of that class.



The keyword static

has a completely different meaning and is only used for class members that are not bound to an instance.

+2


source







All Articles