Re: [Vala] Dynamic arrays in Vala - example for newbie
- From: lariamat <interflug1 gmx net>
- To: Leonti Bielski <prishelec gmail com>
- Cc: Vala-list gnome org
- Subject: Re: [Vala] Dynamic arrays in Vala - example for newbie
- Date: Tue, 31 Mar 2009 00:54:15 +0200
try this:
/-----------------------------------------------
string[] a;
a = string[0];
a += "sometext";
a += "sometext1";
a += "sometext2";
...
/-------------------------------------------------
Regards, lariamat
Am Dienstag, den 31.03.2009, 00:14 +0200 schrieb Leonti Bielski:
Ok, thanks for the advise then.
Now I have different problem. If I do the code below inside a
function, it works:
/-----------------------------------------------
string[] a;
a= {};
a += "sometext";
/-------------------------------------------------
But if I do initialization outside the scope to make array global:
string[] a;
And then inside the function:
/-------------------------------
a= {};
a += "sometext";
--------------------------------
I get following error:
error: ‘a_size’ undeclared (first use in this function)
How do I declare global array properly?
Leonti
On Mon, Mar 30, 2009 at 11:06 PM, Feng Yu <rainwoodman gmail com> wrote:
Use string[] instead of GLib.Array
The rule of thumb is to avoid GLib.Array, if possible.
vala array implements a resize method.
On Mon, Mar 30, 2009 at 2:46 PM, Leonti Bielski <prishelec gmail com> wrote:
Hello!
I'm writing an application and I've come to the point where I need to
use dynamic arrays.
I tried Garray:
GLib.Array<string> test_calls; // it's declared from the start to be global
test_calls = new GLib.Array<string>(false, false, (uint)sizeof(string));
test_calls.append_val("some string");
debug("%s", test_calls.index(0));
It gives me segmentation fault.
How do I do this properly?
I've been searching the whole day for example in Vala and couldn't find one :(
Thanks. Leonti
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]