相关疑难解决方法(0)

Ruby each_with_index偏移量

我可以在each_with_index循环迭代器中定义索引的偏移量吗?我的直接尝试失败了:

some_array.each_with_index{|item, index = 1| some_func(item, index) }
Run Code Online (Sandbox Code Playgroud)

编辑:

澄清:我不想要数组偏移我希望each_with_index中的索引不是从0开始,而是例如1.

ruby iteration

82
推荐指数
3
解决办法
7万
查看次数

标签 统计

iteration ×1

ruby ×1