对于 ruby .times,是否有一个计数器或者我是否必须执行以下操作
count = 0
4.times do
puts "this is the count #{count}"
count = count+1
最佳答案
是的,times
产生一个计数器:
4.times do |count|
puts "this is the count #{count}"
end
关于ruby - 循环 ruby 的简单计数器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7267549/