Re: [Vala] functions and null
- From: tecywiz121 <tecywiz121 hotmail com>
- To: Pavol Klačanský <pavol klacansky com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] functions and null
- Date: Wed, 19 Jan 2011 16:17:51 -0500
On Wed, 2011-01-19 at 22:11 +0100, Pavol Klačanský wrote:
Hi, why this code doesn't work
Item item = null;
parse_content(item);
parse_content(Item item) {
stderr.printf("argh");
}
reports
** (process:674): CRITICAL **: xml_parser_parse_content: assertion
`item != NULL' failed
This doesn't work because Vala automatically adds an assertion to check
if function parameters are null. This behavior is the standard for GLib
programs.
If you would like to pass a null value into a function, try (untested):
void parse_content(Item? item) { ... }
The question mark makes the variable 'nullable' meaning that it is
allowed to be null.
I hope that helps,
Sam
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]