The fact that this works comes from the fact that internally empty strings can be represented by the string reference pointer being nil.
However, it is not guaranteed that every empty string is identified this way.
It may be well possible for a plugin to create a string that with a length of zero, which then is not a simple nil pointer. And then the “s is nil” test will fail, despite the string being empty.
Someone should tell Andy, probably. Unless someone from RS could tell us that even the plugins won’t be able to do this (unless you’re using Theo’s “faststrings”).
Unless they’ve changed something since I left, RB’s string foundation code will never return a non-NULL zero-char string object. NULL is the only canonical representation of the empty string.
“(c is true) = false.”
hahaha! ;)
— Thomas Tempelmann · Mar 24, 02:46 AM · #
The fact that this works comes from the fact that internally empty strings can be represented by the string reference pointer being nil.
However, it is not guaranteed that every empty string is identified this way.
It may be well possible for a plugin to create a string that with a length of zero, which then is not a simple nil pointer. And then the “s is nil” test will fail, despite the string being empty.
Someone should tell Andy, probably. Unless someone from RS could tell us that even the plugins won’t be able to do this (unless you’re using Theo’s “faststrings”).
— Thomas Tempelmann · Mar 24, 02:54 AM · #
Unless they’ve changed something since I left, RB’s string foundation code will never return a non-NULL zero-char string object. NULL is the only canonical representation of the empty string.
— Mars Saxman · Mar 25, 08:52 PM · #