Skip to content

proposal: strconv: add Not #37836

@carnott-snap

Description

@carnott-snap

I find myself writing this function (or code snippet) far too frequently, one possible option is to implement a turnery function, but that has been turned down before. Assuming this too has not been declined, could some flavour be added to strconv:

func Not(b bool) string {
        if b {
                return "not "
        }
        return ""
}

I am quite amenable to other names, and there may be a better way to support other languages or functionality:

func When(b bool, s string) string {
        if b {
                return s
        }
        return ""
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions