Skip to content

Create LeftAssociative overload with more friendly factory #127

@gumbarros

Description

@gumbarros

Is possible to create a more friendly overload?

Actual:

var equal = Terms.Text("=").Or(Terms.Text("=="));
var notEqual = Terms.Text("<>").Or(Terms.Text("!="));

var equality = relational.LeftAssociative(
    (equal, static (a, b) => new BinaryExpression(BinaryExpressionType.Equal, a, b)),
    (notEqual, static (a, b) => new BinaryExpression(BinaryExpressionType.NotEqual, a, b))
);

Suggestion:

var equal = Terms.Text("=").Or(Terms.Text("==")).Then(_=>BinaryExpressionType.Equal);
var notEqual = Terms.Text("<>").Or(Terms.Text("!=")).Then(_=>BinaryExpressionType.NotEqual);

var equality = relational.LeftAssociative([equal, notEqual], (a,b, operation)=>{
return new BinaryExpression(operation, a, b);
});

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