Infix wrapper for assign + lockBinding that creates a constant: a binding whose value can not be changed.

x %<c-% value

Arguments

x

unquoted expression naming variable to create

value

constant value

Examples

x %<c-% 10
#' Generates an error:
if (FALSE) x <- 20 # \dontrun{}

# Note that because of R's operator precedence rules, you
# need to wrap compound RHS expressions in ()
y %<c-% 1 + 2
#> [1] 3
y
#> [1] 1
z %<c-% (1 + 2)
z
#> [1] 3