[Pas2js] A pascal version of the C ternary operator ( ? : )
silvioprog
silvioprog at gmail.com
Sat Dec 22 23:11:08 CET 2018
On Sat, Dec 22, 2018 at 10:32 AM warleyalex via Pas2js <
pas2js at lists.freepascal.org> wrote:
> if then else alternative feature ( ? : )
>
> Amazing to see new fetures introduced to pas2js. I must say that I do
> really
> like this syntax.
>
> ------- // pascal version // ------
> var
> msg: String;
> begin
> msg := "There are " + IntToStr(n) + " user" + if (n>1) then "s" else "";
> end;
> ----------------------------------------
>
It sounds very good and will be useful.
For the first time in history a language will make ternary operators
readable. :-)
> This can allow to eliminate the need for some intermediate variables and
> repetitions.
> This is a pascal version of the C ternary operator ( ? : )
>
> //--- JS output //--------------------------------------------------
> var msg = "";
> msg = "There are "+n.toString()+" user"+((n>1)?"s":"");
> ---------------------------------------------------------------------
--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20181222/8df78fc7/attachment-0001.html>
More information about the Pas2js
mailing list