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
Post a Comment
Comments are very welcome, but please be aware that I moderate all comments, so there will be a delay before your comment appears.
Advertising spam and the rare abusive, hateful or racist comments will be blocked and reported.
Finally, should you have a query about, or a bug report for, one of my programs or libraries please use the relevant issue tracker rather than posting a comment to report it.
Thanks