Skip to content

IsNoneOr(predicate) #61

@julienroubieu

Description

@julienroubieu

Hi Nils!

I couldn't find a method to check if an Option is empty or satisfies a given predicate.
I'm looking for an equivalent for scala's forall behaviour on Option.

I'm seeing two ways of getting this currently:

if (!opt.HasValue || opt.Exists(Predicate)) { ... }
if (opt.Map(Predicate).ValueOr(true)) { ... }

Is there some easier way that I missed?

If not, would you consider adding something like if (opt.IsEmptyOr(Predicate)), which would be more readable IMO. I might work on a PR if you are willing to accept it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions