Replaces if statement with ternary expression.