Hi:

> ```
> static bool is_empty(string str) {
>     return str[0] == '\0' || str == null;
> }
> ```
>
> However, running my code, I get the following message repeatedly in my
> terminal: ** (main.exe:2288): CRITICAL **: is_empty: assertion 'str !=
> NULL' failed
>
> What am I doing wrong?

You should use:

static bool is_empty(string? str) {


By adding the '?' after the variable type, you say Vala compiler that it
can be NULL. If you don't put that, the Vala compiler will include a
NON-NULL check at the begining, which is what is showing that message.



--
Nos leemos

RASTER (Linux user #228804)
ras...@rastersoft.com http://www.rastersoft.com

_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to