gpt4 book ai didi

ruby - 为什么 ruby​​ 中的 backward for 循环不起作用?例如。我在 10..1

转载 作者:数据小太阳 更新时间:2023-10-29 07:01:34 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Is there a reason that we cannot iterate on “reverse Range” in ruby?

这就像变魔术一样。

for i in 1..10
...
end

这个向后的 for 循环应该也能正常工作,这不是很直观吗?

for i in 10..1
...
end

如果有一些语法原因导致这不起作用,我觉得必须更改 ruby​​ 以允许它。以这种方式编写反向 for 循环非常直观。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com