if-otherwise: Postfix if-otherwise logic

Description Usage Arguments See Also Examples

Description

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.

Usage

1
2
3
prior %if% proposition

prior %if% proposition %otherwise% alternate

Arguments

prior

The value to be returned if proposition evaluates to TRUE.

proposition

The logical statement to evaluate

alternate

The value to be returned if proposition evaluates to FALSE.

prior %if% proposition

An %if% statement.

See Also

Other postlogic: unless-then

Examples

1
2
3
4
5
6
7
    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

postlogic documentation built on Jan. 11, 2020, 9:35 a.m.