From: Dave Thomas Date: 2001-11-05T23:46:18+09:00 Subject: [ruby-talk:24391] Re: documentation for builtin classes Niko Schwarz writes: > Hello, Would someone give me a hint where to find up to date > documentation for the builtin classes of ruby? I don't find it, I > always check in the pragmatic user guide, but it does not contain, > e.g. the grep method (which i found by try and error *sigh*) Grep is a method of the Enumerable module, which is mixed in to classes such as Array: http://dev.rubycentral.com/book/ref_m_enumerable.html#grep We decided not to include the documentation of (most) mixed in methods in every class that uses them, as that would add quite a lot of bulk to the reference. If you download the 'ri' tool, you'd also be able to say dave[~/tmp 8:45:20] ri grep -------------------------------------------------------- Enumerable#grep enumObj.grep( pattern ) -> anArray enumObj.grep( pattern ) {| obj | block } -> anArray ------------------------------------------------------------------------ Returns an array of every element in enumObj for which Pattern === element. If the optional block is supplied, each matching element is passed to it, and the block's result is stored in the output array. (1..100).grep 38..44 #=> [38, 39, 40, 41, 42, 43, 44] c = IO.constants c.grep(/SEEK/) #=> ["SEEK_END", "SEEK_CUR", "SEEK_SET"] res = c.grep(/SEEK/) {|v| IO.const_get(v) } res #=> [2, 1, 0] Regards Dave