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

String.lastIndexOf documentation should clarify what position is returned #41893

Closed
jamesderlin opened this issue May 13, 2020 · 0 comments
Closed
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core type-documentation A request to add or improve documentation

Comments

@jamesderlin
Copy link
Contributor

https://api.dart.dev/stable/2.8.2/dart-core/String/lastIndexOf.html states:

Returns the position of the last match pattern in this string, searching backward starting at start, inclusive:

Is 'foobar'.lastIndexOf('foo') supposed to return 0 or 2?

I think that this would be clearer as something like "Returns the starting position".

Additionally, the examples unfortunately happen to use search patterns that match only a single character. The lone example that uses a longer search pattern is for a case where the string isn't found. Changing the examples to use longer search patterns also would clarify the expected behavior.

@srawlins srawlins added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core type-documentation A request to add or improve documentation labels May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-core type-documentation A request to add or improve documentation
Projects
None yet
Development

No branches or pull requests

2 participants