TERNARY
NAME
ternary - is an operator that takes three arguments. The arguments and result can be of different types.
SYNOPSIS
( expression ) ? expression : expression
DESCRIPTION
A traditional if-else construct in Extenso is written:
if a > b then
result = x;
else
result = y;
endif
This can be rewritten as the following ternary statement:
result = (a > b) ? x : y;
The second expression should be between ( and ) if the expression is complex.
EXAMPLES
Note: In the followings examples, the _ between the { should be removed to make it work.
res={_{i=(1>0) ? 5 : 6 ; i;}}. return res=5.
res={_{i=(1>2) ? 5 : 6 ; i;}}. return res=6.
res={_{i=(1>0) ? 5*2 : 6 ; i;}}. return res=10.
res={_{i=(1>0) ? (7>2)?1:2 : 6 ; i;}}. return res=1.
res={_{i=(1>0) ? (1>2)?1:2 : 6 ; i;}}. return res=2.
res={_{i=(1>4) ? (1>2)?1:2 : 6 ; i;}}. return res=6.
sn_path = (abc eq undefined || abc eq '')?'allo':(abc .+ "12345");
abc="def";
sn_path = (abc ne undefined)?abc .+ '12345' : abc; sn_path;
abc=undefined;
sn_path = (abc ne undefined)?abc .+ '12345' : abc; sn_path;
return res=def12345undefined.
SEE ALSO
AUTHOR
Written by Pierre Laplante, <laplante@sednove.com>
MODIFICATIONS
1.0 2014-09-09 21:24:14 laplante@sednove.com
Edit