Skip to content

Multiple candidates

Josh Hiles edited this page Dec 23, 2023 · 1 revision

It's not usually a good idea to try more than one alternative simultaneously. Behavior isn't guaranteed to be isolated and reporting + visualization get quite a bit harder. Still, it's sometimes useful.

To try more than one alternative at once, add names to some Try blocks:

public bool CanAccess(IUser user)
{
    return Scientist.Science<bool>("widget-permissions", experiment =>
    {
        experiment.Use(() => IsCollaborator(user));
        experiment.Try("api", () => HasAccess(user));
        experiment.Try("raw-sql", () => HasAccessSql(user));
    });
}