Times

Times#

  • Starts at 0 index
5.times { |i| puts "hello #{i}" }
# Output:
$ruby main.rb
hello 0
hello 1
hello 2
hello 3
hello 4
  • Times without index:
5.times { puts "hello" }
# Output
$ruby main.rb
hello
hello
hello
hello
hello