Why the coalescing comparison operators exist
The complete source of operators_coalescing_benefit.ek9, compiled by the EK9 compiler. Shown on operators.html.
#!ek9 defines module site.operators.coalescingbenefit defines function functionToGetBird1() as pure <- rtn as String: String() functionToGetBird2() as pure <- rtn as String: "Duck" defines program CoalescingBenefit() stdout <- Stdout() //Values to work with bird1 <- functionToGetBird1() bird2 <- functionToGetBird2() //Without using new operators answerA <- String() if not bird1? answerA := bird2 else if not bird2? answerA := bird1 else answerA := bird1 < bird2 <- bird1 else bird2 //With the new operator answerA := bird1 <? bird2 //With the new operator and function calls answerA := functionToGetBird1() <? functionToGetBird2() //Without the new operators, you would want to avoid multiple calls! stdout.println(answerA)
Download operators_coalescing_benefit.ek9
Output
Duck