Ruby for LoopRuby 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 rangeExample: Output: ![]() Ruby for loop using arrayExample: Output: ![]()
Next TopicRuby while and do while loop
|