Re: [Vala] Array as big as an enum



On Mon, 2016-08-29 at 23:47 +0200, rastersoft wrote:
Sorry, I found how to do that:

int[] blah = new int[LAST_ELEMENT];

If you want to avoid having a LAST_ELEMENT value, something like this
will also work:

    ((GLib.EnumClass) typeof(Foo).class_ref ()).n_values

I'm not necessarily advocating it, but if you really want to keep your
API clean it's an option.


El 29/08/16 a las 23:45, rastersoft escribió:

Hi all:

I have an enum with several elements, and I need to create an array
with
the same number of elements. In C I define a last element with a
known
name (eg: "LAST_ELEMENT"), and use "int blah[LAST_ELEMENT];" to
create
the array. How can I do that in Vala?

Thanks.

Attachment: signature.asc
Description: This is a digitally signed message part



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