Re: [Vala] How to check if string is empty




In Vala you can simply just check for str != "", this is enough.

No, if str is nullable it's semantically different, because str != "" will be generated as

if (g_strcmp0 (_tmp1_, "") != 0) {
  ..
}

This will be TRUE for _tmp1_ being NULL because NULL isn't "" ( and g_strcmp0 will return -1 because NULL is < everything)
so if str is nullable, str != "" means NULL or not empty.


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