check_odd()
and check_is_odd()
functions check whether
the input is an odd number. The check_odd()
function raises an error
if the input is not an odd number, while check_is_odd()
returns
TRUE
if the input is an odd number, and FALSE
otherwise.
Value
check_odd()
: Returns the original value ofnum
if it is an odd number. Raises an error message ifnum
is not an odd number.check_is_odd()
: Logical value,TRUE
if the input is an odd number, andFALSE
otherwise.
Examples
# Examples for check_odd()
# ------------------------
check_odd(5)
#> [1] 5
try(check_odd(4))
#> Error in check_odd(4) : Expected 'num' to be an odd number but got 4
# Examples for check_is_odd()
# ---------------------------
check_is_odd(5)
#> [1] TRUE
check_is_odd(4)
#> [1] FALSE