Javatpoint Logo
Javatpoint Logo

Ruby for Loop

Ruby for loop iterates over a specific range of numbers. Hence, for loop is used if a program has fixed number of iterations.

Ruby for loop will execute once for each element in expression.

Syntax:


Ruby for loop using range

Example:

Output:

Ruby for 1


Ruby for loop using array

Example:

Output:

Ruby for 2






Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA