What would be the following situation using if ternary ?
if StrToInt(Edit1.Text) < 30 then
Edit2.Text := '30'
else if StrToInt(Edit1.Text) in [30..50] then
Edit2.Text := '40'
else
Edit2.Text := '50'
What would be the following situation using if ternary ?
if StrToInt(Edit1.Text) < 30 then
Edit2.Text := '30'
else if StrToInt(Edit1.Text) in [30..50] then
Edit2.Text := '40'
else
Edit2.Text := '50'
v = StrToInt(Edit1.Text);
Edit2.Text = IfThen(v < 30, '30', IfThen(v in [30..50], '40', '50'));
In programming languages, the expression :?
, is known to be a Ternary Operator , several languages
Delphi
However from Delphi7, there is the option to use IfThen
:
IfThen([Expressão boleana], [Se verdadeiro], [Se falso])
However, you can not do this:
y:= IfThen(x <> 0, 1/x, 0);
Being necessary to use the traditional way:
if x <> 0 then y := 1/x else y := 0;