1. What is an iterator in Ruby? A. A predefined set of instructions for performing a specific task B. A data structure that stores elements sequentially C. A method that iterates over elements in a collection D. A method that repeatedly calls a block of code Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
2. Which method is used to create an enumerator in Ruby? A. Enumerable.create B. Enumerator.create C. Enumerable.new D. Enumerator.new Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
3. What is the purpose of the each method in Ruby iterators? A. To iterate over each element in a collection B. To filter elements in a collection C. To map elements to a new collection D. To sort elements in a collection Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
4. What does the map method do in Ruby enumerators? A. Sorts elements in a collection B. Removes duplicate elements from a collection C. Selects elements from a collection based on a condition D. Applies a block of code to each element and returns a new collection Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
5. How do you define a custom iterator in Ruby? A. By using the define_iterator keyword B. By extending the Iterator class C. By creating a method that yields to a block of code D. By invoking the create_iterator method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
6. What does the select method do in Ruby enumerators? A. Sorts elements in a collection B. Filters elements in a collection based on a condition C. Removes duplicate elements from a collection D. Sorts elements in a collection Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
7. What is the purpose of the reduce method in Ruby enumerators? A. To sort elements in a collection B. To map elements to a new collection C. To combine all elements in a collection into a single value D. To filter elements in a collection Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
8. What is an enumerator in Ruby? A. A data structure for storing elements sequentially B. A method that repeatedly calls a block of code C. A predefined set of instructions for performing a specific task D. An object that can be used to iterate over a collection Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
9. Which method is used to convert a collection into an enumerator in Ruby? A. to_enum B. enum_for C. to_enumerator D. enumerator Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
10. What does the zip method do in Ruby enumerators? A. Removes duplicate elements from a collection B. Applies a block of code to each element and returns a new collection C. Reverses the order of elements in a collection D. Combines elements from multiple collections into arrays Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board