July 30, 2025
There are new language features coming in the next version of Delphi. I just blogged about one for Embarcadero.
This is a beta blog post I just published:
https://blogs.embarcadero.com/coming-in-rad-studio-13-a-conditional-ternary-operator-for-the-delphi-language/
Yes, it's a ternary operator, like ?: in other languages, but it's called if. So if will be both a keyword and an operator. This is a big change, and the most voted features on the old QP. I'm quite happy about it.
This blog post is based on a pre-release version of the RAD Studio software. No feature is committed until the product’s GA release.
posted by
marcocantu @ 2:41AM | 4 Comments
[0 Pending]
Coming Delphi language extension A conditional ternary operator
Nice!
30 years of Delphi and still in its infancy. Long live... :-)
Comment by Guido on July 30, 06:09
Coming Delphi language extension A conditional ternary operator
Great feature! ✅
Pascal/Delphi is like math — from basics to advanced, once it’s
written, it just works the same. Timeless and reliable.
#Delphi #CleanCode #RADStudio13
Comment by Marcos Nielsen
[http://www.softniels.com]
on July 30, 22:11
Coming Delphi language extension A conditional ternary operator
There already is a function IfThen, overloaded for strings (in System.StrUtils) and numbers (in System.Math), that does just that.
Picking up from there, it is straightforward to write a generic function:
type
generic = record
class function IfThen<T> (condition : boolean; const TrueValue, FalseValue : T) : T; static;
end;
class function generic.IfThen<T> (condition : boolean; const TrueValue, FalseValue : T) : T;
begin
if condition then IfThen := TrueValue
else IfThen := FalseValue;
end;
If Delphi would have standalone generic functions, that would remove a lot of syntactic noise.
Comment by Jost Riedel
[http://www.reservoir2.de]
on August 19, 04:38
Coming Delphi language extension A conditional ternary operator
Jost Riedel: But there is a huge difference between *any* `IfThen` function and the new `if` operator: The function will always evaluate the expressions for *both* "branches", while the operator will only evaluate *one* of them.
Comment by Andreas Rejbrand
[https://rejbrand.se/]
on August 21, 16:58
There are currently 0 pending (unapproved) messages.