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



Martin Ertsås <mertsas cisco com> writes:

You could use out instead to populate the list:

static void populate_list (out Slist<string> list) {
}

And call this method with:

var list = new Slist<string> ();
populate_list (out list);

Thank you.

I originally tried the 'out' modifier, and I got a warning[1].
I looked at the tutorial[2] and it seems to indicate the 'ref'
modifier is used as in your example. It indicates that the 'out' 
modifier is called like this:

         SList<string> list;
         populate_list (out list);

It would be initialized on the callee side.  

         static void populate_list (out SList<string> list) {
                list = new SList<string> ();
                [...]
         } 

[1] - use of possibly unassigned parameter.
[2] - http://live.gnome.org/Vala/Tutorial#Parameter_Directions 
-- 
Regards,
Brian Winfrey




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