AL language now supports ternary (conditional) operator. The ternary operator? : known from other programming languages, streamlines conditional operations in code, enhances readability and reduces verbosity.
The following examples show how the code GetBooleanText()
can be rewritten using the ternary operator to be less verbose and more succint.
Without the ternary operator:
procedure GetBooleanText(b: Boolean): Text;
begin
if b then
exit('True')
else
exit('False');
end;
With the ternary operator
procedure GetBooleanString(b: Boolean): Text;
begin
exit(b ? 'True' : 'False');
end;
Regards,
Tharanga Chandrasekara