开发者

Find the source file for class / method using ri or fastri for ruby

For example I do

$fri group_by
---------------------------------------------------- Enumerable#group_by
     enum.group_by {| obj |开发者_C百科 block }  => a_hash
------------------------------------------------------------------------
     Returns a hash, which keys are evaluated result from the block, 
     and values are arrays of elements in enum corresponding to the key.

        (1..6).group_by {|i| i%3}   #=> {0=>[3, 6], 1=>[1, 4], 2=>[2, 5]}

Except I'm pretty sure that group_by is not part of the standard ruby library. How to find out which library is monkey patching Enumerable?


group_by is part of the ruby core since 1.8.7.


use the ri_for gem:

>> require 'ri_for'
>> Enumerable.ri_for :group_by
sig: Enumerable#group_by arity 0
appears to be a c method
Original code signature: sig: Enumerable#group_by arity 0
#parameters signature: group_by( [] )
Searching ri for
sig: Enumerable#group_by arity 0
...
Nothing known about Enumerable
(end ri)
=> "#"

(the fact that it's a c method means it's probably in core)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜