关于在ruby循环的结果前面添加数字排名的非常基本的问题.
@model.each do |foo|
#code here to put the number of the element in the loop starting at 1 and going up.
puts foo.title
end
Run Code Online (Sandbox Code Playgroud)
哪个理想情况下会打印出以下结果.
1 titlea
2 titleb
3 titlec
Run Code Online (Sandbox Code Playgroud)
无法在任何地方找到这个 - 任何帮助表示赞赏.
谢谢