Get the higher-or-equal temperature threshold.
← Operators and Expressions · Ref: Q1219
The >=? coalescing operator returns the greater-or-equal of two values, handling unset gracefully.
higherOrEqual() as pure -> left as Float, right as Float <- rtn as Float: left >=? right
If both values are set and different, >=? returns the larger one (same as >?). If both are equal, it returns that value. If one is unset, it returns the set one. If both unset, the result is unset.
The full coalescing family is <?, >?, <=?, >=?. See Q1227 for all four operators side by side.
Do not confuse any coalescing operator with :=? (guarded assignment). See Q1226 for the contrast.
Example
defines module qa.operators.coalescegte.float defines function higherOrEqual() as pure -> left as Float right as Float <- rtn as Float: left >=? right defines program CoalesceGteFloatDemo() stdout <- Stdout() // === BOTH THRESHOLDS SET — returns the higher === warningThreshold <- 35.0 criticalThreshold <- 40.0 upperLimit <- higherOrEqual(warningThreshold, criticalThreshold) stdout.println(`Upper threshold: ${upperLimit}`) // === EQUAL THRESHOLDS — returns the shared value === limitA <- 37.5 limitB <- 37.5 sameLimit <- higherOrEqual(limitA, limitB) stdout.println(`Shared threshold: ${sameLimit}`) // === ONE THRESHOLD UNSET — returns the set one === configuredLimit <- 42.0 missingLimit <- Float() onlyLimit <- higherOrEqual(configuredLimit, missingLimit) stdout.println(`Configured threshold: ${onlyLimit}`) // === BOTH UNSET — result is unset === absentFirst <- Float() absentSecond <- Float() bothMissing <- higherOrEqual(absentFirst, absentSecond) if bothMissing? stdout.println(`Threshold: ${bothMissing}`) else stdout.println("No temperature threshold configured")
Other ways to ask this
- How do I find the greater-or-equal of two Float values when one threshold might be unset?
- Two temperature thresholds are defined but one might be missing — pick the higher or equal.
- In Java I'd need null checks before Math.max with nullable doubles. What does EK9 use?
- Migrating from Go where I compare float64 with nil checks — does EK9 have a greater-or-equal coalescing?
Coming from another language?
Java: a == null ? b : b == null ? a : a >= b ? a : b. Python: max(a, b) handles equality naturally. Kotlin: listOfNotNull(a, b).maxOrNull(). EK9: left >=? right — one operator handles all cases including equality.
Keywords: temperature, coalescing, equal, >=?, higher, greater-or-equal, float, threshold