Skip to content

Add takeTo to Traversable #2963

@scabug

Description

@scabug

In the past few months I have sometimes wanted a takeTo method, which would take all elements up to and including the first for which a predicate was true. Or, in other words, the following equivalency would be true:

collection.takeTo(p) == collection.takeWhile(!p).init

I haven't found easy way to simulate such method using the existing ones. I have either used sliding, with the inconvenients it presents, or simply went about my code in a completely different manner.

So I ask for this method to be added. The name I propose is based on the until/to distinction used for ranges.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions