This construction allows logical statements to be placed after the value to be returned. Take note that the ` as other custom infix operators and so care should be taken that the effect is as desired.
prior %if% propositionprior %if% proposition %otherwise% alternate
The value to be returned if proposition evaluates to TRUE.
The logical statement to evaluate
The value to be returned if proposition evaluates to FALSE.
An %if%
statement.
Other postlogic: unless-then
# NOT RUN {
x <- 1
x <- (x+1) %if% is.numeric(x) %otherwise% "Hmm this isn't right O.o"
x # 2
x <- 1i
x <- (x+1) %if% is.numeric(x) %otherwise% "Hmm this isn't right O.o"
x # Hmm this isn't right
# }
Run the code above in your browser using DataLab