New inline if statement slated for Delphi 13

The new feature currently planned for release in the forthcoming Delphi 13 that I'm most excited about is the inline if statement.

According to Marco Cantu's blog post, the new syntax is like this:

X := if Left < 100 then 22 else 45;

Another use is something like this:

ShowMessage(if Odd(X) then 'odd' else 'even');

The values returned from the then and else parts must be of the same or compatible type.

Apart from being really chuffed that this feature is being added I'm just as happy that the syntax is Pascal like, and is therefore more readable than the cryptic C style ?: construct.

Also pleasing is the fact that Embarcadero have gone with version number 13 instead of being ridiculously superstitious!

Since Delphi 13 has yet to be released the usual disclaimer applies that this feature is not guaranteed to be included.

Comments

Popular posts from this blog

Initialising dynamic arrays

Deleting elements from a dynamic array

New Array Utilities Library Unit released