Skip to main content

pre_eval_switch

Function pre_eval_switch 

Source
fn pre_eval_switch(
    args: &[Arg],
    env: &Environment,
    context: &BuiltinContext<'_>,
) -> Result<RValue, RError>
Expand description

switch(EXPR, …) — only evaluate the matching branch.

Critical for rlang’s ns_env() which has switch(typeof(x), builtin=, special=ns_env("base"), ...) — the ns_env("base") must NOT be evaluated unless typeof(x) is “builtin” or “special”.

@param EXPR expression to evaluate (determines which branch) @param … named branches (name=value) and optional default @return value of the matching branch @namespace base