开发者

Simple counter for loops ruby

For the ruby .times do is there a counter or do I have to do the following

count = 0
4.times开发者_如何学C do
puts "this is the count #{count}"
count = count+1


Yes, times yields a counter:

4.times do |count|
  puts "this is the count #{count}"
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜