Re: [Vala] functions and null



2011/1/19 Pavol Klačanský <pavol klacansky com>:
Hi, why this code doesn't work

Here the item is null
Item item = null;

parse_content(item);

And in this function you declared parameter as non-null
parse_content(Item item) {
       stderr.printf("argh");
}

reports
** (process:674): CRITICAL **: xml_parser_parse_content: assertion
`item != NULL' failed

Unlike Java and other languages Vala has idea of nullable references.

You should declare your function as

parse_content(Item? item) {

pay attention to the question mark after the parameter type.



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