[Vala] How to check if string is empty



Hello!

I've just heard about Vala and I've been messing around with it these
past days.

However, I came across a problem. I need to check if some strings aren't
empty, and I realized there's no method in Vala that's equivalent to
C#'s `string.IsNullOrEmpty(string)`.

I tried setting up a static method to check if the given string is empty:
```
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?

Thanks!
-- 
Alexandre Oliveira
  167F D82F 514A E8D1 2E9E
  C62D 1B63 9D4A 7E9D DA9D


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