Hello readers! This article is written by a Chinese author named 豌豆花下猫, who is writing his first English article with the super help of ChatGPT. I ...
For further actions, you may consider blocking this person and/or reporting abuse
Two comments
if(but alsocase) is an expression. Ruby has also (if I remember correctly) the classical C versiona ? b : c, this is aligned with the redundancy added to the language by design (another example is the length of an array: you can usesize,lengthorcount, as you like). I prefer the "ifexpression" solution: it is much easier to read than the cryptica ? b : c.(if cond then A else B)format is Ada (together with thecaseexpression too). It is a fairly recent addition (Ada 2002? 2012?) and I think it has been added motivated by its use in contracts (pre/post conditions), but I think it is popular also with inline functions.and/orambiguity, Ada solves it by making parenthesis mandatory if a boolean expression has bothandandor. Ada coders just hate (to be said with the voice of of the Grouchy Smurf 😏) ambiguous situations that could give rise to bugs.On a personal level, I like the Ada solution: it is quite readable and in some context helps making the code clear by removing some scaffolding. Note the emphasis on some context: indeed, it is a construct that can be easily abused. I like the idea of having the possibility of choosing the form that I think it is more suited for every single case.
Thank you for sharing your knowledge.