Search⌘ K
AI Features

Solution: Print a Partial Collection

Explore how to iterate over a collection in Ruby and print elements based on a condition. Learn to use the each loop with an if statement and the break keyword to control program flow and output messages. After this lesson, you'll understand how to print partial collections and improve your program's presentation.

Flowchart of a possible solution

We are given a collection of words and are tasked to print the words if they fulfill a condition. Below is the flowchart of a possible solution:

As we can see, each indicates ...