Skip to content

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

@jamesderlin

Description

@jamesderlin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-coretype-documentationA request to add or improve documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions