# ‘When-Otherwise’ Condition Expression

In Quantity System Calculator (DLR) I’ve implemented a new way of conditional expression that can be written continuously and fits into one line.

I called it ‘when-otherwise’ expression

‘[true result] when [test] otherwise [false result] when …’

let us define a simple function with it

f(x) = x when x< 10 otherwise x^2 when x<20 otherwise x^5

I know that I am going against the famous ‘if-then’ statement, however ‘if-then’ statement is an imperative syntax, and I needed a functional statement that fits in one line.

when I was thinking about this new syntax I also didn’t ignore the question syntax of C,C++, C#

‘Test?True Part, False Part’ , but also this syntax is somehow complex to use, and give me a headache actually.

thats why I invented it this way. You can see that the result part precede the condition part and the syntax is truly easy to remember (hard to type) but easy to extend.