From: Phrogz Date: 2007-12-20T09:40:07+09:00 Subject: Re: slicing in ruby On Dec 19, 5:11 pm, Robert Citek wrote: > Discovered this with a brute-force search: > > ruby -e 'puts [].methods.sort' | > while read name ; do > echo == $name > ri Array."${name}" | cat > done > > Interestingly, a lot of methods didn't return anything via ri. For example: > > $ ri Array.methods > Nothing known about Array.methods C:\Documents and Settings\gavin.kistner>qri methods ------------------------------------------------------ Multiple choices: Kernel#methods, Object#methods C:\Documents and Settings\gavin.kistner>qri Object.methods --------------------------------------------------------- Object#methods obj.methods => array ------------------------------------------------------------------------ Returns a list of the names of methods publicly accessible in _obj_. This will include all the methods accessible in _obj_'s ancestors. class Klass def kMethod() end end k = Klass.new k.methods[0..9] #=> ["kMethod", "freeze", "nil?", "is_a?", "class", "instance_variable_set", "methods", "extend", "send", "instance_eval"] k.methods.length #=> 42 But yes - documentation helps you find out what methods are available. ^_^ http://phrogz.net/ProgrammingRuby/builtins.html#builtinclassesandmethods http://phrogz.net/ProgrammingRuby/lib_standard.html#standardlibrary http://www.ruby-doc.org/