Does Vala have function static variables?
By "function static variable" I mean a variable declared inside a function that keeps its value between invocations, like in the following c 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);
}
No, it doesn't.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With