Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segmentLength is confusing #11821

Open
Jasper-M opened this issue Dec 5, 2019 · 1 comment
Open

segmentLength is confusing #11821

Jasper-M opened this issue Dec 5, 2019 · 1 comment

Comments

@Jasper-M
Copy link
Member

@Jasper-M Jasper-M commented Dec 5, 2019

The scaladoc of segmentLength says

Computes length of longest segment whose elements all satisfy some predicate.

returns the length of the longest segment of this sequence such that every element of the segment satisfies the predicate p.

From reading the name of the method and this explanation, which of these is true?

"yxxyyxxxyy".segmentLength(_ == 'x') == 0

"yxxyyxxxyy".segmentLength(_ == 'x') == 3

Maybe I'm crazy but I would think the second one. However, it's the first.

Same thing for the overload with a from parameter.

@SethTisue

This comment has been minimized.

Copy link
Member

@SethTisue SethTisue commented Dec 5, 2019

a pull request bringing the documentation in line with reality would be welcome.

evidence that the behavior is as-intended: it used to be called prefixLength. @szeiger do you happen to recall why it changed? (in your commit scala/scala@3993526)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.