Skip to content

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

@alexrp

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. 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions