Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Else parser #59

Closed
sebastienros opened this issue Jan 4, 2022 · 1 comment
Closed

Else parser #59

sebastienros opened this issue Jan 4, 2022 · 1 comment

Comments

@sebastienros
Copy link
Owner

Create an Else parser that is invoked when the previous one is not matched. Identical to Then but with the opposite trigger.

Can be used to return an object as a fallback (or default value).

Example:

var p = a.Or(b).Else(() => new DefaultValue()); // if neither a or b were parsed

Note this might be doable with ZeroOrOne and then check if the results is set

@sebastienros
Copy link
Owner Author

ZeroOrOne(a.Or(b)).Then(x => x ?? new DefaultValue());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant