This example will print the numbers in triangle format with increment numbers array = (1..10).to_a order = 1 limit = 4 (1..limit).each do |number| array[order - 1, number].each{|i| print "#{i} " } # will print it in line order += number puts # will print a break between your lines end Output
1
2 3
4 5 6
7 8 9 10
What are #method_missing and #send? Why are they useful?
How to add/remove elements to Array in Ruby?
What are the various Ruby runtimes, and how are they different?
how to create an array with Array.[](*args) in Ruby ?
Ruby program to add two integer numbers
Ruby program to generate random numbers
Creating Array with Array.new(size, obj) in Ruby
How to Sort Array in Ruby?
How to Get Input with Gets in Ruby
How to Replace array elements in Ruby?
Ruby program to Calculate the factorial of given number
How to get index of array element in Ruby
Ruby program to print an array
Ruby program to check whether the given number is Armstrong
What are some of your favorite gems? What are their alternatives?
Ruby program to check whether the given number is prime or not
How to shuffle an array in Ruby?
How to create two dimensional array in ruby?
Ruby program to check whether the given number is palindrome
What's the difference between a lambda, a block and a proc?
Ruby program to reverse a string
Program to Print Triangle of Numbers in Ruby
Ruby program to print Fibonacci series