11. How do you create a custom enumerator in Ruby? A. By defining a method that yields to a block of code B. By invoking the create_enumerator method C. By extending the Enumerator class D. By using the define_enumerator keyword 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
12. What is the purpose of the each_with_index method in Ruby enumerators? A. To map elements to a new collection B. To iterate over each element in a collection along with its index C. To sort elements in a collection D. To map elements to a new 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
13. What does the cycle method do in Ruby enumerators? A. Removes duplicate elements from a collection B. Sorts elements in a collection C. Iterates over each element in a collection indefinitely D. Repeatedly applies a block of code to each element 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
14. What does the find method do in Ruby enumerators? A. Returns an array containing elements that satisfy a given condition B. Returns the last element that satisfies a given condition C. Returns the total number of elements that satisfy a given condition D. Returns the first element that satisfies a given condition 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
15. What is the purpose of the times method in Ruby enumerators? A. Executes a block of code a specified number of times B. Iterates over each element in a collection C. Converts a collection into an enumerator D. Sorts 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
16. What does the 'any?' method do in Ruby enumerators? A. Checks if the enumerator is empty B. Checks if no elements satisfy a given condition C. Checks if all elements satisfy a given condition D. Checks if any element satisfies a given condition 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
17. What does the inject method do in Ruby enumerators? A. Sorts elements in a collection B. Converts a collection into an array C. Combines all elements in a collection into a single value D. Iterates over each element in a collection and applies a block of code to accumulate a value 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
18. What does the grep method do in Ruby enumerators? A. Sorts elements in a collection B. Filters elements in a collection based on a regular expression 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
19. What is the purpose of the drop_while method in Ruby enumerators? A. Applies a block of code to each element and returns a new collection B. Sorts elements in a collection C. Skips elements in a collection until a given condition is met D. Removes elements from a collection until a given condition is met 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
20. What does the max_by method do in Ruby enumerators? A. Returns the maximum value in a collection B. Returns the element with the maximum index C. Returns the element with the maximum length D. Returns the element with the maximum value based on a given condition 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