我想检查一个变量的值 - aVar 是否等于几个字母之一:
if aVar != "S" || "X" {println("NO")}
这给出了错误:
Binary operator || cannot be applied to operands of type String
一个很小的问题,却找不到答案
最佳答案
如果您想知道 aVar
是 S 还是 X:
if (aVar=="S")||(aVar=="X") {...}
关于swift - 如何使用 "OR"在 Swift 中比较字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32482655/