Can't test for an empty _groupKey
Summary: The issue is basically that [[_groupKey -> _isEmpty]] always comes out false, even if the actual key was empty.
Eric's original email:
I'm grouping FAQ items by Category.
In theory, everything should have a Category, but if something doesn't, the QText/QL
[[_groupKey]]
prints out
which is not very informative or desirable. If I try to explicitly catch that case with:
""#### [[_if(_groupKey._isNonEmpty, _groupKey, ""(no category)"")]]
...I get an error: _groupKey didnt receive a Thing value
If I try either of
""#### [[_if(_isNonEmpty(_groupKey), _groupKey, ""(no category)"")]]
""#### [[_if(_groupKey -> _isNonEmpty, _groupKey, ""(no category)"")]]
...it simply doesn't work; the header still shows up.
On some investigation, the issue turns out to be that _groupBy() is being lazy, and slamming a missing value to the default of the grouped PType. But Eric's expected behavior is entirely reasonable, and probably more correct. Moreover, _groupKey is defined as Optional -- we're just always slamming a value into it, to make the code a bit easier.
So the correct solution is to bite the bullet, and make the code properly robust in the face of an actually-empty _groupKey.