开发者

Simple counter for loops ruby

开发者 https://www.devze.com 2023-04-01 00:36 出处:网络
For the ruby .times do is there a counter or do I have to do the following count = 0 4.times开发者_如何学C do

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

精彩评论

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

关注公众号