Re: [Vala] Array as generic type not allowed? Can't ArrayList<string[]>



于 08/31/2012 06:52 PM, Luca Bruno 写道:
On Fri, Aug 31, 2012 at 12:48 PM, Just Fill Bugs <mozbugbox yahoo com au>wrote:

I tried to create a list of string[] but it's not allowed on vala version
0.16.1.

using Gee;
void main() {
     var strings_list = new ArrayList<string[]>();
}

gives:
error: `string[]' is not a supported generic type argument, use `?' to box
value types

And adding "?" still give the same error.

Should generic support array as a type? Is it a bug?


It's not a bug, it's intentionally not supported as said by the compiler.
You can either create a class to encapsulate your array, or use other data
structures such as GLib.GenericArray or Gee.ArrayList and so on.



But array was represented as pointer, hence fit into a pointer. Isn't the requirement for generic type is fitting into a pointer size?






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]