Predicate-based object replacement

default_ifnot(x, test = function(x) TRUE, default = x)

default_if_not(x, test = function(x) TRUE, default = x)

Details

Meant to be pipe-friendly and similar in spirit to tidyr::replace_na, only: (i) this function is scalar, operating on the entire object as a single unit and (ii) one passes an arbitrary predicate function test that takes a single argument (x).