On Friday, 10 May 2024 at 15:23:39 UTC, Andy Valencia wrote:
On Friday, 10 May 2024 at 03:07:43 UTC, Steven Schveighoffer
wrote:
Yes, we say that a type has "truthiness" if it can be used in
a condition (`while`, `if`, `assert`, etc).
So if I may ask for one more small clarification... WRT
"truthiness", I've observed that empty arrays are treated as
false, non-empty as true.
Arrays evaluate to true in boolean conditions if their `.ptr`
field is non-null. This is bug-prone and I hope we can remove
this in the next edition.
However, although I thought a string was basically an immutable
array of characters, "" is treated as true, not false?
A string literal's `.ptr` field is always non-null, because it is
null-terminated.