try(cast(10)) # errors outside of favr calling context
x <- 1.5
cast_if_not(x = lossy(integer()))
class(x) # integer
enforce(x ~ list(cast(double()), recycle(5)))
class(x) # numeric
length(x) # 5
x <- 1.5
enforce(x ~ coerce(type = integer(), size = 5, lossy = TRUE))
class(x) # integer
length(x) # 5
Run the code above in your browser using DataLab