Re: [Vala] How to check if GLib.List is empty?



On 02/12/2014 16:34, Виталий Кирсанов wrote:
Hm, indeed. The following piece of code works fine:

int main(string[] argv)
{
    List<string> list = new List<string>();
    assert( list == null );
    return 0;
}


So this seems to be the answer to my question. But still there are two
weird things in my opinion:

   - Why I need to call operator new if the result value is still null?
   Can't I simply declare a reference List<string> list; and then call e.g.
   append()?
Yes, you can. "new List()" is just "null".
   - I thought that only references appended with question mark sign (e.g.
   List<string>?) can be null, cant' they?
There are several exceptions due to historical reasons. Null is quite
weak in Vala by default in several places.
There's an experimental non-null flag for valac, but that's not much
worked on.

Best regards,


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