swfit中是否有与javascript中的以下内容相同的东西?
optionalString = maybeThisExists || ""
myFunc(maybeThisExists || "")
在swfit中我应该这样做吗?
myFunc(maybeThisExists ? maybeThisExists! : "")
答案 0 :(得分:2)
使用??
运算符:
let optionalString = maybeThisExists ?? ""
如果optionalString
不为零,则 maybeThisExists
的内容为maybeThisExists
,否则会获得“”。