3

The Random class method Random.rand is aliased as rand (i.e. equivalent to Random.rand). Is there anyway to get a listing of the class method aliases used by Ruby?

Not sure that Ruby documentation offers a complete list as it does identify rand as an alias of Random.rand but there is no mention that srand is an alias yet it can be invoked using srand or Random.srand

I eventually answered my own question - please have a look below.

4

1 回答 1

1

编辑我的原始问题:

这个问题的根源在于对 Ruby Random 类文档参考http://ruby-doc.org/core-2.0/Random.html的误解,该参考引用了 Random.rand 类方法的别名 rand。事实证明 rand 和 srand 调用了内核实例方法。要调用 Random 类的类方法 rand 和 srand,您需要提供完整解析的调用,例如 Random.rand 或 Random.srand

因此,我正在寻找的列表实际上是内核实例方法的内核文档http://www.ruby-doc.org/core-1.9.3/Kernel.html

于 2013-03-04T20:52:11.820 回答