Variable question

Why thats is possible

void func (Variable v){...}
int[]a = {1,2,3};

and thats give an error, is that a bug?


error: initializer list used for 'GLib.Variant', which is neither array nor struct

void func (int[] arr){...}

works fine

An initializer list doesn’t have a type, so this code:

var a = {1,2,3};

fails with:

error: initializer list used for unknown type

You need to use the full array instantiation syntax when not assigning to an array or struct type:

var a = new int[] {1,2,3};
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.