From: "David A. Black" Date: 2009-09-13T21:54:53+09:00 Subject: Re: All the core function are buit-in? Hi -- On Sun, 13 Sep 2009, Free Kickr wrote: > Thanks, I download the files and have a brief read of the 4 files: > > enum.c > lib/set.rb > lib/soap/property.rb > ext/enumerator/enumerator.c > > Which was told related to Enumerable module, but from those, I still did > not understand the how the iterator implementation such as "collect, > select, inject...etc". > > In my imagination, I thought, there's Enumerable.rb which include the > method > def select... > def collect... > ... > > But it seems I was wrong, Could you pls give a little bit explaination? Usually toward the end of the C files there's a section where the C functions are bound to Ruby methods, like this: rb_define_method(rb_mEnumerable,"sort", enum_sort, 0); rb_define_method(rb_mEnumerable,"sort_by", enum_sort_by, 0); rb_define_method(rb_mEnumerable,"grep", enum_grep, 1); rb_define_method(rb_mEnumerable,"find", enum_find, -1); etc. That's your mapping from C to Ruby. David -- David A. Black, Director Ruby Power and Light, LLC (http://www.rubypal.com) Ruby/Rails training, consulting, mentoring, code review Book: The Well-Grounded Rubyist (http://www.manning.com/black2)