Re: [Vala] how to pass a List by reference?



Abderrahim Kitouni <a kitouni gmail com>
writes:

Hello,

2011/10/13 bsquared <bwcode4u gmail com>:

I am guessing that I'm going about this wrong, but I want to populate a list
from a static method.

    static void populate_list (ref SList<string> list) {
           list.append("");
    }

I am getting a compiler error:
error: Cannot capture reference or output parameter

The above compiles without problems for me (valac 0.14.0). This error
probably means that you are trying to use this variable from a lambda
expression.

Another solution is to use libgee: libgee's lists are objects and
don't need any special treatment (just pass them normally and you can
call list.add with no problems)

HTH,
Abderrahim
_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list

Yes that does help.  I was attempting to use from with a lambda.  Thank you.
-- 
Regards,
Brian Winfrey




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