使用未解决的运算符< = [英] Use of unresolved operator <=

查看:101
本文介绍了使用未解决的运算符< =的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Swift 3 for循环,但是我一直没有成功.这是我所拥有的:

I am trying to use Swift 3 for-loops, but I have been unsuccessful. Here is what I have:

for assumedPayRate: Double in (0.25..<=billRate) where assumedPayRate += 0.25 {

..<=上,它给我错误:

使用未解决的运算符'..< ='

Use of unresolved operator '..<='

这是Swift 2的原始版本:

Here is the original Swift 2 version:

for var assumedPayRate:Double = 0.25; assumedPayRate <= billRate; assumedPayRate += 0.25 {

如何解决此错误?

推荐答案

在Swift中不存在运算符..<=,并且您的语法无效.使用stride代替:

The operator ..<= doesn't exist in Swift and your syntax is invalid. Use stride instead:

// Assuming billRate is a Double
for assumedPayRate in stride(from: 0.25, through: billRate, by: 0.25) {
    // Do your things
}

这篇关于使用未解决的运算符&lt; =的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆