Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Swift中使用范围内的负数?_Swift_Switch Statement_Operators_Negative Number - Fatal编程技术网

如何在Swift中使用范围内的负数?

如何在Swift中使用范围内的负数?,swift,switch-statement,operators,negative-number,Swift,Switch Statement,Operators,Negative Number,我有以下代码: switch self.score { case 1: self.score = self.score - 2 case -10...-10000: // ! Expected expression after unary operator println("lowest score") self.score = -10 default:

我有以下代码:

switch self.score
        {
        case 1:
            self.score = self.score - 2
        case -10...-10000: // ! Expected expression after unary operator
            println("lowest score")
            self.score = -10
        default:
            self.score = self.score - 1
        }
我还尝试了
案例-1000…-10:
。两者都会得到相同的错误
!一元运算符后应为表达式


我真正想做的是在一个开关的情况下,
case。。。b
是一个“闭合间隔”和开始时间 必须小于或等于间隔的末尾。此外,必须使用加号或减号 用空格(或括号中的数字)与
隔开,因此

工作


case是否可以尝试用括号括起来?不幸的是,这也不起作用。@webmagnetics:在文档的“Where”部分中::“开关case可以使用Where子句检查其他条件…”
case -10000...(-10):
case -10000 ... -10:
case let x where x <= -10:
case ...(-10):