Joining an empty list should return an empty list #4853
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #4852.
Note that this changes behavior introduced in TiddlyWiki 5.1.22 by #4396. Specifically, #4396 made join return
[""]
(a list containing a single empty string) if passed an empty input list, while this PR makes join return[]
(an empty list) if passed an empty input list. Before #4396, join would return[null]
(a list containing a single null) on empty input, which was causing Red Screen of Death errors. While returning[""]
does stop the crashes, I believe that it's not what users would expect, and users would expect join to return an empty list when given empty input.I would also like code-style comments: I've written
if(result.length === 0) return [];
as a single line here. Should I instead write this with braces? It seems short enough to merit a one-liner, but some people don't like that.