Skip to content

Return empty entries on split#1

Merged
Olof-Lagerkvist merged 2 commits into
LTRData:masterfrom
Erik-White:return-empty-from-split
Jan 24, 2024
Merged

Return empty entries on split#1
Olof-Lagerkvist merged 2 commits into
LTRData:masterfrom
Erik-White:return-empty-from-split

Conversation

@Erik-White

Copy link
Copy Markdown

The behaviour of the ReadOnlySpan<char> split extensions methods in SpanSplitExtensions differ from the .NET string split methods. The behaviour should be aligned to standard .NET implementation, see https://github.com/Microsoft/referencesource/blob/master/mscorlib/system/string.cs#L1010

This can easily be demonstrated:

Console.WriteLine(string.Empty.Split('/').Count());
>> 1
Console.WriteLine(string.Empty.AsMemory().Split('/').Count());
>> 0

@Olof-Lagerkvist

Copy link
Copy Markdown
Member

Good find, thanks a lot!
Yes I agree that the behavior should be as close as possible to String.Split behavior to make migration easier.

@Olof-Lagerkvist Olof-Lagerkvist merged commit 6b28542 into LTRData:master Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants