This post is part of the New Functionality In Microsoft Dynamics 365 Business Central 2024 Wave 2 series in which I am taking a look at the new functionality introduced in Microsoft Dynamics 365 Business Central 2024 Wave 2.
The 2nd of the new functionality in the Development section is use the ternary operator when coding in the AL language.
The ternary operator ? : known from other programming languages streamlines conditional operations in code, enhances readability and reduces verbosity. It’s particularly useful for simple conditions, promoting code clarity and intent-focused programming. By allowing variable initialization within the same line, it ensures proper assignment and minimizes code length. With this release, AL now also supports the ternary operator.
Enabled for: Admins, makers, marketers, or analysts, automatically
Public Preview: Oct 2024
General Availability: Oct 2024
Feature Details
The ternary operator ? :
can now be used to assign one of two values to a variable, depending on the condition of an expression.
Here’s an example of using if-then-else as until now and the new ternary operator.
Click to show/hide the New Functionality In Microsoft Dynamics 365 Business Central 2024 Wave 2 Series Index
What should we write about next?
If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.