Ruby的while循环里if条件如何改写为长尾?
- 内容介绍
- 文章标签
- 相关推荐
本文共计203个文字,预计阅读时间需要1分钟。
在Ruby中,使用以下代码:
rubyif (tickFormat.length + 12==tickFormat.length + 24) && i==1 while (i % tickFormat.length !=0) if (i % 2 !=0) tickFormat.at(i)[1]='' end i +=1 endend
我得到了第二个结束语句的意外的keyword_end。如果结束语句是意外的,可能是由于代码逻辑错误或格式问题。
在 Ruby中使用以下代码:if (tickFormat.length > 12 && tickFormat.length < 24) i = 1 while(i < tickFormat.length) do if (i%2 != 0) tickFormat.at(i)[1] = '' end i++ end end
我得到第二个“结束”语句的“意外的keyword_end”.如果我删除while循环代码运行没有错误.有任何想法吗?
试试这个:if (tickFormat.length > 12 && tickFormat.length < 24) i = 1 while(i < tickFormat.length) do if (i%2 != 0) tickFormat.at(i)[1] = '' end i += 1 end end
i语法在Ruby中不起作用
本文共计203个文字,预计阅读时间需要1分钟。
在Ruby中,使用以下代码:
rubyif (tickFormat.length + 12==tickFormat.length + 24) && i==1 while (i % tickFormat.length !=0) if (i % 2 !=0) tickFormat.at(i)[1]='' end i +=1 endend
我得到了第二个结束语句的意外的keyword_end。如果结束语句是意外的,可能是由于代码逻辑错误或格式问题。
在 Ruby中使用以下代码:if (tickFormat.length > 12 && tickFormat.length < 24) i = 1 while(i < tickFormat.length) do if (i%2 != 0) tickFormat.at(i)[1] = '' end i++ end end
我得到第二个“结束”语句的“意外的keyword_end”.如果我删除while循环代码运行没有错误.有任何想法吗?
试试这个:if (tickFormat.length > 12 && tickFormat.length < 24) i = 1 while(i < tickFormat.length) do if (i%2 != 0) tickFormat.at(i)[1] = '' end i += 1 end end
i语法在Ruby中不起作用

