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



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



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