ruby-on-rails - 在 Ruby on Rails 中使用多个迭代器进行索引

标签 ruby-on-rails ruby iterator

我有以下循环,效果很好:

@publishers.each do |proj, vp|

我想做这样的事情

@publishers.each_with_index do |proj, vp, i|

有没有办法让它工作?

谢谢!

最佳答案

@publishers.each_with_index do |(proj, vp), i|

关于ruby-on-rails - 在 Ruby on Rails 中使用多个迭代器进行索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7132441/

相关文章:

java - 关闭 java.util.Iterator

ruby-on-rails - 如何通过本地移动设备连接到 localhost Rails 站点?

Ruby 文件读取并行性

ruby-on-rails - Rails ActiveRecord::多参数分配错误

c++ - 我如何错误地使用 vector 迭代器?

python - 迭代时从 itertools.combinations 中删除元素?

ruby-on-rails - 我应该关心 Newrelic Rails 应用程序中的 DOM 处理时间吗?

ruby-on-rails - 使用 Pusherapp 的私有(private) channel (使用 Rails)

ruby-on-rails - Devise omniauthable 使用 `Could not find a valid mapping for path` 破坏 Omniauth 身份验证

ruby - return retval() if retval() —— 有没有一种方法可以在 Ruby 中编写它而不调用 retval 函数两次?