Python&Swift 三元(目)运算

发布时间 2023-08-07 16:19:01作者: wonderhoi

Python的三元运算写法:

is_true = True
result = 'TRUE' if is_true else 'FALSE'
# output: TRUE

Swift的三元运算写法:

isTrue = true
result = isTrue ? "TRUE" : "FALSE"
// output: TRUE