Open moodymudskipper opened 2 years ago
We already have swap = TRUE to change foo <- if(cond) "a" else "b" to if(cond) foo <- "a" else foo <- "b".
swap = TRUE
foo <- if(cond) "a" else "b"
if(cond) foo <- "a" else foo <- "b"
It would make sense to make stopifnot diagram friendly too.
stopifnot
stopifnot has some advanced options (usually not used), and a small difference with if(cond) stop() in that the conditions are not coerced to logical.
if(cond) stop()
So stopifnot(cond) seems equivalent to if(!isTRUE(cond)) stop("`cond` is not TRUE").
stopifnot(cond)
if(!isTRUE(cond)) stop("`cond` is not TRUE")
stopifnot(cond1, cond2) seems equivalent to :
stopifnot(cond1, cond2)
if(!isTRUE(cond1)) { stop("`cond1` is not TRUE") } else if(!isTRUE(cond2)) { stop("`cond2` is not TRUE") }
We might just not support more advanced uses since they're not obvious to translate and rarely used.
We already have
swap = TRUE
to changefoo <- if(cond) "a" else "b"
toif(cond) foo <- "a" else foo <- "b"
.It would make sense to make
stopifnot
diagram friendly too.stopifnot
has some advanced options (usually not used), and a small difference withif(cond) stop()
in that the conditions are not coerced to logical.So
stopifnot(cond)
seems equivalent toif(!isTRUE(cond)) stop("`cond` is not TRUE")
.stopifnot(cond1, cond2)
seems equivalent to :We might just not support more advanced uses since they're not obvious to translate and rarely used.