doing comparison if else in JasperReports

iReport (JasperReports) uses a Ternary operator. For example, consider the following logic: IF boolean condition THEN execute true code ELSE execute false code END IF Using a ternary operator, this becomes: boolean condition ? execute true code : execute false code When using a variable with the following expression: $F{column_value}.intValue() == 42 ? “Life, Universe, … Read more

C#’s null coalescing operator (??) in PHP

PHP 7 adds the null coalescing operator: // Fetches the value of $_GET[‘user’] and returns ‘nobody’ // if it does not exist. $username = $_GET[‘user’] ?? ‘nobody’; // This is equivalent to: $username = isset($_GET[‘user’]) ? $_GET[‘user’] : ‘nobody’; You could also look at short way of writing PHP’s ternary operator ?: (PHP >=5.3 only) … Read more