Skip to content

Pure Value Matches #758

Closed
Closed

Description

@FreeApophis

Idea to think about:

  • currently you always have to provide a Func even in simple cases where you return only a value in each case:

Example:

        => validationResult
            .Match(notValidated: _ => HttpStatusCode.BadRequest, valid: _ => HttpStatusCode.OK, invalid: _ => HttpStatusCode.BadRequest);

And this would allow code like this:

    private static HttpStatusCode ToStatusCode(this DataValidationResult validationResult)
        => validationResult
            .Match(notValidated: HttpStatusCode.BadRequest, valid: HttpStatusCode.OK, invalid: HttpStatusCode.BadRequest);

Possible Strategies:

  • Either everything is a func or everything is a value. (Above)
  • Allow Values only in cases where there is an empty class provided. (Like Option)

Pro:

  • simpler code in a few cases
  • Similarity to Option

Contra:

  • could lead to overload problems

Activity

  1. FreeApophis commented on Sep 24, 2026

    @FreeApophis
    MemberAuthor

    Closed: see parent item.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions