Find the earlier meeting time from two optional schedule slots.
← Operators and Expressions · Ref: Q1211
The <? coalescing minimum operator returns the earlier of two Time values, handling unset gracefully.
earlierTime() as pure -> left as Time, right as Time <- rtn as Time: left <? right
If both times are set, <? returns the earlier one. If one is unset (empty slot), it returns the available time. If both are unset, the result is unset.
This is a COMPARISON operator — it picks the smaller value. Do not confuse it with :=? (guarded assignment), which assigns only if the target is unset. See Q1226 for a side-by-side contrast.
See Q1092 for min/max coalescing overview. See Q1187 for Time comparison.
Example
defines module qa.operators.coalescemin.time defines function earlierTime() as pure -> left as Time right as Time <- rtn as Time: left <? right defines program CoalesceMinTimeDemo() stdout <- Stdout() // === BOTH SLOTS FILLED — returns the earlier === morningSlot <- 09:30 afternoonSlot <- 14:00 firstAvailable <- earlierTime(morningSlot, afternoonSlot) stdout.println(`First available: ${firstAvailable}`) // === ONE SLOT EMPTY — returns the filled one === confirmedSlot <- 11:00 emptySlot <- Time() onlyOption <- earlierTime(confirmedSlot, emptySlot) stdout.println(`Only option: ${onlyOption}`) // === BOTH SLOTS EMPTY — result is unset === noSlotA <- Time() noSlotB <- Time() noTime <- earlierTime(noSlotA, noSlotB) if noTime? stdout.println(`Time: ${noTime}`) else stdout.println("No meeting time available")
Common mistakes
E50060 — Time has no isBefore() method; use the '<?' coalescing-minimum operator to pick the earlier value. See ek9 -h E50060 for details.
Incorrect:
left.isBefore(right)
Correct:
left <? right
Other ways to ask this
- How do I select the minimum Time when one schedule slot might be unfilled?
- Two calendar slots are offered but one might be empty — pick the earlier time.
- In Java I'd check for null before comparing LocalTime objects. What does EK9 use?
- Migrating from Kotlin where I use listOfNotNull then minOrNull — what is the EK9 way?
Coming from another language?
Java: a == null ? b : b == null ? a : a.isBefore(b) ? a : b. Python: min(t for t in [a, b] if t is not None). Kotlin: listOfNotNull(a, b).minOrNull(). EK9: left <? right — one operator handles all cases.
Keywords: schedule, coalescing, <?, earlier, minimum, slot, time, meeting