~male = female
Ordinality for human hierarchies: CEO > manager > worker
Commutativity for human action: Punch human + kick human = damaged human
Kick human + punch human = damaged human
Mathematical interfaces are different from mathematical primitives which I believe you have mistakenly combined into a singular concept in your response. var x;
if (someExpression) {
x = True;
}
//var x is undefined
Example 2: var x;
x = someExpression ? true : false;
// use of ternary expression prevents var x from ever being undefined.
The ternary expression forces you to handle the alternative case while the if expression can leave a singularity. A hole where x remains undefined. isXgreaterThanY = x > y;
isWlessThan2 = w < 2;
isSubExpressionTrue = isXgreaterThanY & isWlessThan2 ? False : True;
isFactNotTrue = isSubExpressionTrue ? False : True;
Yes technically the ternary expressions are still nested in a way here, but when reading this code you don't have to dive in deep past the symbolic name. if true:
sendDataToIO(data)
//the alternative of not sending data to IO is not a singularity. It is also required... a ternary expression makes less sense here.
Last but not least: The ternary expression is also a bit weak because it only deals with two possible branches: True/False. The safest and most readable primitive to deal with multiple branches of logic is exhaustive pattern matching. Both Rust and Haskell have a form of this. In rust, it is the match keyword.
For example I tend not to prefer putting data into a class if it's not needed, but we had one interviewer who wanted all my logic as methods on a class even though it's fine to have functions operating on a data structure. Not a big deal either way right? But there it is... With the influx of candidates they measure this bs.