User bio

I'm currently a developer for the InterSystems iService customer support platform. As such, I've become an expert in the Angular framework and how that can integrate with the IRIS database.

In my free time, I am a musician (trumpet player for 25 years) and avid gamer.

Member since Apr 19, 2021
Posts:
Replies:

OH! Today I learned as well! It never occurred to me that I'd need to double space after the else to make that work. Thanks, Robert!

For me personally, I prefer using one-line if statements over post-conditionals as I find they're easier to read (even as someone that has been using ObjectScript for many, many years), and especially for newer developers that aren't used to ObjectScript syntax where post-conditionals could be a bit confusing at first.

if option1 do ##Class(FEatures.Option1).DoSomething()

NOTE: The following turns out to not be the case, and has been corrected by Robert below. Leaving this here for context.
The thing to note about this (and this also applies to post-conditionals as well) is you cannot use either if you intend to include an Else along with it (sadly, the one-line else isn't supported in ObjectScript). If you intend to use if/else, then it must be a discrete if block even if there's only a single line of code inside it.

You can also shorthand the ObjectScript call to %FromJSON() by using:
set list = [].%FromJSON(jsonExport)

or

set list = {}.%FromJSON(jsonExport)

When you set an ObjectScript variable equal to either [] (DynamicArray) or {} (DynamicObject), the variable becomes an instance of the respective dynamic entity class automatically, so it saves you having to type out the entire class reference.

Certifications & Credly badges:
Robbie has no Certifications & Credly badges yet.
Followers:
Following: