- Log in to post comments
With all due respect, Python, C#, Java, Rust, and other languages also allow multiple commands on the same line just like ObjectScript does. I see that Go doesn't allow this.
ObjectScript simply evaluates expressions (arithmetic and logical) strictly left-to-right. Using parentheses gives you control, and has the added benefit of making a complex expression easier to read for other developers. Would you ever write this in any language?
if a = 3 && b = 4 && c = 5 || d = 6 {write "succeeded"} else {write "failed"}
No. You'd write it like this:
if (a = 3) && (b = 4) && ((c = 5) || (d = 6)) {write "succeeded"} else {write "failed"}
- Log in to post comments
Please avoid using the legacy single-line If and Else commands. Needing to use 2 spaces after the Else is confusing at best and causes problems at worst. If you want a single line If, this is fine:
if option1 { do ##Class(Features.Option1).DoSomething() }A developer will quickly understand the code above and it's straightforward to modify it if more code needs to run based on the condition, or if an Else needs to be added.
On the topic of post-conditionals supposedly being confusing, other languages have similar things ("ternary operator"):
set w = "goodbye" set:(z < 5) w = "hello"w = "hello" if z < 5 else "goodbye"w = (z < 5) ? "hello" : "goodbye"
- Log in to post comments
I agree. I think you can remove that extra try/catch.