Skip to content

first_non_empty #931

@ittaiz

Description

@ittaiz
Contributor

See if we can replace first_non_empty with code from skylib (existing or to contribute back).
Motivation for generalization- Recurring pattern of target attribute and if not fallback to toolchain definition

Activity

borkaehw

borkaehw commented on Jan 30, 2020

@borkaehw
Contributor

The code is simple but I don't get the use case of it

# Return the first non-empty arg. If all are empty, return the last.
def first_non_empty(*args):
    for arg in args:
        if arg:
            return arg
    return args[-1]

What inputs do you expect here?

ittaiz

ittaiz commented on Jan 31, 2020

@ittaiz
ContributorAuthor

I wrote it in the motivation above: Recurring pattern of target attribute and if not fallback to toolchain definition. This is how we use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ittaiz@borkaehw

        Issue actions

          first_non_empty · Issue #931 · bazel-contrib/rules_scala