[Pas2js] A pascal version of the C ternary operator ( ? : )
    warleyalex 
    warleyalex at yahoo.com.br
       
    Sat Dec 22 14:32:51 CET 2018
    
    
  
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;
----------------------------------------
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":"");
---------------------------------------------------------------------
--
Sent from: http://pas2js.38893.n8.nabble.com/
    
    
More information about the Pas2js
mailing list