Ternary and nullcheck operators
Ternary operator ? :
? :condition ? statementIfConditionIsTrue : statementIfConditionIsFalseExample
with math from std:math
func sinc(x float)
put x != 0.0 ? math.sin(x)/x : 1.0
endNull-conditional operator ::
::Example
with exceptions from std:exceptions
with console from std:io
var doStuff = { x =>
x :: raise exceptions.ArgumentNullException("{} is null".format(nameof(x)))
}
try
doStuff(null)
catch(default e)
console.out(e.message)
end
//Output: x is null
func add(a,b) requires (a :: false) and (b :: false)
put a + b
endLast updated