From: Dave Thomas Date: 2001-02-25T15:46:46+09:00 Subject: [ruby-talk:11511] ANN: ri - the Ruby Interactive reference Have you forgotten the parameters that each_with index passes to it's block? Just type: % ri each_with_index and you'll see: ------------------------------------------------------------------ enumObj.each_with_index {| obj, i | block } -> nil ------------------------------------------------------------------ Calls block with two arguments, the item and its index, for each item in enumObj. hash = Hash.new %w(cat dog wombat).each_with_index {|item, index| hash[item] = index } hash #=> {"dog"=>1, "wombat"=>2, "cat"=>0} Hazy on what methods are defined in the Math module? % ri Math ------------------------------------------------------------------- module: Math ------------------------------------------------------------------- The Math module contains module functions for basic trigonometric and transcendental functions. ------------------------------------------------------------------- atan2, cos, exp, frexp, ldexp, log, log10, sin, sqrt, tan ------------------------------------------------------------------- ri contains the information from Programming Ruby on 42 built-in classes and modules, and over 700 built-in methods. What command line could be complete without a copy of ri? Snag one while they last at: http://www.pragmaticprogrammer.com/ruby/downloads/ri.html Dave ps. If anyone writes editor macros that use ri, so that you can pop-up method descriptions while your cursor is on the method name, I'd love to add them to the distribution. Thanks.