From 6326112e16352caad131f1f1580c4621eb7b1d3f Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Tue, 4 Jan 2022 18:39:07 -0600 Subject: [PATCH] Enhanced RDoc for Enumerable (#5393) A little more about the classes that include or extend Enumerable. --- enum.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/enum.c b/enum.c index f8e327ff7f..93041df252 100644 --- a/enum.c +++ b/enum.c @@ -4777,26 +4777,42 @@ enum_compact(VALUE obj) * [1, 2] * nil * - * == \Enumerable in Ruby Core Classes - * Some Ruby classes include \Enumerable: + * == \Enumerable in Ruby Classes + * + * These Ruby core classes include (or extend) \Enumerable: + * + * - ARGF * - Array * - Dir + * - Enumerator + * - ENV (extends) * - Hash * - IO * - Range - * - Set * - Struct + * + * These Ruby standard library classes include \Enumerable: + * + * - CSV + * - CSV::Table + * - CSV::Row + * - Set + * * Virtually all methods in \Enumerable call method +#each+ in the including class: + * * - Hash#each yields the next key-value pair as a 2-element \Array. * - Struct#each yields the next name-value pair as a 2-element \Array. * - For the other classes above, +#each+ yields the next object from the collection. * * == About the Examples + * * The example code snippets for the \Enumerable methods: + * * - Always show the use of one or more \Array-like classes (often \Array itself). * - Sometimes show the use of a \Hash-like class. * For some methods, though, the usage would not make sense, * and so it is not shown. Example: #tally would find exactly one of each \Hash entry. + * */ void