我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

有没有一种优雅的方法可以在for循环的第三位置放置多个语句? [重复]

This question already has an answer here:

  • Multiple variables in for loop in Go 1 answer
  • For loop of two variables in Go 2 answers

I'm writing a for-loop statement, and I need to initialize two local variables to represent the indexes of strings a and b passed to the addBinary function. However, it's not allowed to put 'ia--, ib--' at the third position of for-loop. Is there an elegant way to do this?

func addBinary(a string, b string) string {
    for ia, ib := len(a)-1, len(b)-1; ia >= 0 && ib >= 0; ia--, ib-- {
        // some code
    }
}
</div>

近期文章

  • 如何分割/分割文件中的单词
  • 如何将json转换为未知类型的结构
  • golang-读取字符串参数包括&
  • 如何为所有用户安装golang二进制文件
  • Golang GUI fyne-io帮助设置了吗?
  • 尝试使用通道获取FIFO处理管道
  • 如何编写一个可以接受任何映射的函数[重复]
  • 杜松子酒的web框架限制上传文件大小不起作用
  • go中具有依赖条件的动态数据结构(嵌套json)
  • 在Golang虹膜上的特定位置停止执行请求
  • 如何填充地图
  • TCP连接似乎一次读取太多字节
  • 获取传递的查询字符串
  • 在GO中在代理后面使用SMTP /电子邮件客户端
  • 在Go中读取Cookie
  • 不使用“ go env”中指定的$ GOPATH
  • golang html模板格式不正确
  • 如何制作自己的枚举
  • Go HTTP服务器和Fasthttp中的内存泄漏
  • 如何找出'map [string] [] [] int'是否具有值

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华