Skip to content

Confusing example and behavior regarding If(...).Then(() => ...) #188

Description

@alexrp

The docs have this example:

Func<long, bool> isZero = Lambda<Func<long, bool>>(fun => 
{
    var arg = fun[0];
    If((Expression)(arg.AsDynamic() != 0L))
        .Then(() => Return(true))
        .Else(() => Return(false))
    .End();
}).Compile();

Is this doing what it's supposed to be doing? Trying this locally, .Then(() => ...) binds to ConditionalBuilder.Then(Expression), not CodeGenerator.Then(ConditionalBuilder, Action). This also makes the API a bit unwieldy in general, since I have to write code with casts like this:

If(...)
    .Then((Action)(() =>
    {
        // ...
    }))
.End()

Not sure if I'm misunderstanding something or if this is unintended. 🤔

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions