秘密一
JSL If 语句实际上是一个函数,并且它返回一个值。
print( if ( 1 < 2, "yes", "no" ) )
“是的”
如果你不知道这一点,你可能会写
if ( 1 < 2, print("yes"), print( "no" ) )
这也有效。
秘密二
JSL If 函数需要至少两个论点。 可以有三个以上! 如果有奇数个参数,则最后一个是否则价值。
n = 17;
classification = if(
n<3, "toddlers",
n<13, "children",
n<20, "teens",
"adults"
);
show( n, classification );
n = 17;
分类=“青少年”;
秘密三
JSL If 函数将缺失值处理为既不为真也不为假。 这否则价值不是答案。
n = .;
classification = if(
n<3, "toddlers",
n<13, "children",
n<20, "teens",
"adults"
);
show( n, classification );
n = .;
分类=.;
如果您认为两个缺失值彼此相等,这可能看起来相当令人惊讶。 如果其中一个(或两个)操作数缺少值,JMP 的比较运算符都会返回缺失值。 JMP 使用 isMissing 函数来测试缺失:
n = .;
classification = if(
isMissing(n), "unknown",
n<3, "toddlers",
n<13, "children",
n<20, "teens",
"adults"
);
show( n, classification );
n = .;
分类=“未知”;
秘密四
其实并没有什么秘密,一切都在网络。