cla-bot · GitHub

This PR may be a bit surprising, because it removes func split(separator: Character) and adds in func split(separator: String). To my surprise, even when I left both overloads in, the existing character-based tests were all just using the string version once I added it.

Since the character-based implementation was, as far as I could tell, dead code, I eliminated it.

The implementation tries to use Kotlin split() if we're not omittingEmptySequences, but omittingEmptySequences defaults to true, so a simple "a,b,c".split(separator: ",") will not use Kotlin split().

(I also had to implement a whole separate code path for when the separator is empty, to match Swift's behavior in that case.)

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

Cursor generated a first draft (especially the tests), and I rewrote its output.

Read the original on github.com ↗