Skip to content

Add take function (similar to takeIf) #1

Description

@ngsilverman

Rather than:

fun countBananas(): Int {
    // Count the bananas.

    expect(bananaCount >= 0, "Invalid count: $bananaCount.") {
        bananaCount = 0
    }
    return bananaCount
}

Something like:

fun countBananas(): Int {
    // Count the bananas.

    return expect.take(bananaCount, "Invalid count: $bananaCount.") { it >= 0 } ?: 0
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions