<ppdoc>
<copyright>
Copyright (c) 2001 by Addison Wesley Longman, Inc. This material may
be distributed only subject to the terms and conditions set forth in
the Open Publication License, v1.0 or later (the latest version is
presently available at http://www.opencontent.org/openpub/).
<p/>
Distribution of substantively modified versions of this document is
prohibited without the explicit permission of the copyright holder.
<p/>
Distribution of the work or derivative of the work in any standard
(paper) book form is prohibited unless prior permission is obtained
from the copyright holder.
</copyright>
<class name="Kernel" type="module" ref="xref-000001">
<p/>
  The <modulename>Kernel</modulename> module is included by class <classname>Object</classname>, so its
  methods are available in every Ruby object. The <modulename>Kernel</modulename>
  instance methods are documented in class <classname>Object</classname>
  beginning on page 351. This section documents the module methods.
  These methods are called without a receiver and thus can be called in
  functional form.
<p/>
  <methods type="class">
        <method name="Array" ref="Array">
      <callseq>
        Array( <em>arg</em> ) <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns <em>arg</em><tt>.to_a</tt>.
<p/>
<codefragment>
<fullcode><![CDATA[         Array(1..5)
]]></fullcode><rubycode>
<tr>
  <td><tt>Array(1..5)</tt></td>
  <td>&#187;</td>
  <td><tt>[1,<nbsp/>2,<nbsp/>3,<nbsp/>4,<nbsp/>5]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="Float" ref="Float">
      <callseq>
        Float( <em>arg</em> ) <returns><obj>aFloat</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns <em>arg</em> converted to a float. Numeric types are
      converted directly, <tt>nil</tt> is converted to <tt>0.0</tt>, and
      the rest are converted using <em>arg</em>.to_f.
<p/>
<codefragment>
<fullcode><![CDATA[        Float(1)
        Float(nil)
        Float("123.456")
]]></fullcode><rubycode>
<tr>
  <td><tt>Float(1)</tt></td>
  <td>&#187;</td>
  <td><tt>1.0</tt></td>
</tr>
<tr>
  <td><tt>Float(nil)</tt></td>
  <td>&#187;</td>
  <td><tt>0.0</tt></td>
</tr>
<tr>
  <td><tt>Float("123.456")</tt></td>
  <td>&#187;</td>
  <td><tt>123.456</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="Integer" ref="Integer">
      <callseq>
        Integer( <em>arg</em> ) <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Converts <em>arg</em> to a <classname>Fixnum</classname> or <classname>Bignum</classname>. Numeric types 
      are converted directly (with floating point numbers being
      truncated). If <em>arg</em> is a <classname>String</classname>, leading radix
      indicators (<tt>0</tt>, <tt>0b</tt>, and <tt>0x</tt>) are honored. This
      behavior is different from that of <cim><file>string</file><front>String</front><back>to_i</back><mref>to_i</mref></cim>.
<p/>
<codefragment>
<fullcode><![CDATA[         Integer(123.999)
         Integer("0x1a")
         Integer(Time.new)
]]></fullcode><rubycode>
<tr>
  <td><tt>Integer(123.999)</tt></td>
  <td>&#187;</td>
  <td><tt>123</tt></td>
</tr>
<tr>
  <td><tt>Integer("0x1a")</tt></td>
  <td>&#187;</td>
  <td><tt>26</tt></td>
</tr>
<tr>
  <td><tt>Integer(Time.new)</tt></td>
  <td>&#187;</td>
  <td><tt>1023599977</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="String" ref="String">
      <callseq>
        String( <em>arg</em> ) <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Converts <em>arg</em> to a <classname>String</classname> by calling its
      <meth>to_s</meth> method.
<p/>
<codefragment>
<fullcode><![CDATA[         String(self)
         String(self.type)
         String(123456)
]]></fullcode><rubycode>
<tr>
  <td><tt>String(self)</tt></td>
  <td>&#187;</td>
  <td><tt>"main"</tt></td>
</tr>
<tr>
  <td><tt>String(self.type)</tt></td>
  <td>&#187;</td>
  <td><tt>"Object"</tt></td>
</tr>
<tr>
  <td><tt>String(123456)</tt></td>
  <td>&#187;</td>
  <td><tt>"123456"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="` (backquote)" ref="_bq">
      <callseq>
        `<em>cmd</em>` <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the standard output of running <em>cmd</em> in a
      subshell. The built-in syntax <tt>%x{...}</tt>      
      described
      on page 73 uses this method.
<p/>
<codefragment>
<fullcode><![CDATA[        `date`
        `ls testdir`.split[1]
]]></fullcode><rubycode>
<tr>
  <td><tt>`date`</tt></td>
  <td>&#187;</td>
  <td><tt>"Sun<nbsp/>Jun<nbsp/><nbsp/>9<nbsp/>00:19:37<nbsp/>CDT<nbsp/>2002\n"</tt></td>
</tr>
<tr>
  <td><tt>`ls<nbsp/>testdir`.split[1]</tt></td>
  <td>&#187;</td>
  <td><tt>"main.rb"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="abort" ref="abort">
      <callseq>
        abort
      </callseq>
      <desc>
<p/>
            Terminate execution immediately, effectively by calling
      <tt>Kernel.exit(1)</tt>. 
<p/>
      </desc>
    </method>
<p/>
        <method name="at_exit" ref="at_exit">
      <callseq>
        at_exit <block>{ <blockbody>block</blockbody> }</block>
<returns><obj>aProc</obj></returns>
      </callseq>
      <desc>
<p/>
      Converts <em>block</em> to a <classname>Proc</classname> object (and therefore binds
      it at the point of call) and registers it for      
      execution when the program exits. If multiple handlers are
      registered, they are executed in reverse order of registration.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[      def do_at_exit(str1)
        at_exit { print str1 }
      end
      at_exit { puts "cruel world" }
      do_at_exit("goodbye ")
      exit
]]></fullcode>
def<nbsp/>do_at_exit(str1)
<nbsp/><nbsp/>at_exit<nbsp/>{<nbsp/>print<nbsp/>str1<nbsp/>}
end
at_exit<nbsp/>{<nbsp/>puts<nbsp/>"cruel<nbsp/>world"<nbsp/>}
do_at_exit("goodbye<nbsp/>")
exit
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
goodbye<nbsp/>cruel<nbsp/>world
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="autoload" ref="autoload">
      <callseq>
        autoload( <obj>aModule</obj>, <obj>aFile</obj> )
        <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Registers <obj>aFile</obj> to be loaded (using
      <mmm><file>kernel</file><front>Kernel</front><back>require</back><mref>require</mref></mmm>) the first time that <obj>aModule</obj> (which
      may be a <classname>String</classname> or a symbol) is accessed.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        autoload :MyModule, "/usr/local/lib/modules/my_module.rb"
]]></fullcode>
autoload<nbsp/>:MyModule,<nbsp/>"/usr/local/lib/modules/my_module.rb"
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="binding" ref="binding">
      <callseq>
        binding <returns><obj>aBinding</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a <classname>Binding</classname> object, describing the variable and method 
      bindings at the point of call. This object can be used when calling
      <meth>eval</meth> to execute the evaluated command in this
      environment. Also see the description of <classname>Binding</classname>
      beginning on page 291. 
<p/>
<codefragment>
<fullcode><![CDATA[        def getBinding(param)
          return binding
        end
        b = getBinding("hello")
        eval "param", b
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>def<nbsp/>getBinding(param)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>return<nbsp/>binding</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>b<nbsp/>=<nbsp/>getBinding("hello")</tt></td>
</tr>
<tr>
  <td><tt>eval<nbsp/>"param",<nbsp/>b</tt></td>
  <td>&#187;</td>
  <td><tt>"hello"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="block_given?" ref="block_given_qm">
      <callseq>
        block_given? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <kw>yield</kw> would execute a block
      in the current context.
<p/>
<codefragment>
<fullcode><![CDATA[        def try
          if block_given?
            yield
          else
            "no block"
          end
        end
        try
        try { "hello" }
        try do
          "hello"
        end
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>def<nbsp/>try</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>if<nbsp/>block_given?</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>yield</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>else</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/><nbsp/>"no<nbsp/>block"</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
  <td><tt>try</tt></td>
  <td>&#187;</td>
  <td><tt>"no<nbsp/>block"</tt></td>
</tr>
<tr>
  <td><tt>try<nbsp/>{<nbsp/>"hello"<nbsp/>}</tt></td>
  <td>&#187;</td>
  <td><tt>"hello"</tt></td>
</tr>
<tr>
<td colspan="3"><tt>try<nbsp/>do</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>"hello"</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="callcc" ref="callcc">
      <callseq>
        callcc <block>{| cont | <blockbody>block</blockbody> }</block>
 <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Generates a <classname>Continuation</classname> object, which it passes to the associated
      block. Performing a <em>cont</em><tt>.call</tt> will cause the
      <meth>callcc</meth> to return (as will falling through the end of
      the block). The value returned by the <meth>callcc</meth> is the
      value of the block, or the value passed to
      <em>cont</em><tt>.call</tt>. See <classname>Continuation</classname>
      on page 294 for more details. Also see
      <mmm><file>kernel</file><front>Kernel</front><back>throw</back><mref>throw</mref></mmm> for an alternative mechanism for unwinding a
      call stack.
<p/>
      </desc>
    </method>
<p/>
        <method name="caller" ref="caller">
      <callseq>
        caller( <opt><obj>anInteger</obj></opt> )
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the current execution
      stack---an array containing strings in the form
      ``<em>file:line</em>'' or ``<em>file:line: in `method'</em>''. The
      optional <em>anInteger</em> parameter determines the number of
      initial stack entries to omit from the result.
<p/>
<codefragment>
<fullcode><![CDATA[!-         module Kernel
!-           alias oldc caller
!-           def caller(lev)
!-             res = oldc(lev+1)
!-             res.each {|l| l[0] = 'prog'; l.sub!(/\d+/) { ($&.to_i-7).to_s }}
!-           end
!-         end
         def a(skip)
           caller(skip)
         end
         def b(skip)
           a(skip)
         end
         def c(skip)
           b(skip)
         end
         c(0)
         c(1)
         c(2)
         c(3)
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>def<nbsp/>a(skip)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>caller(skip)</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>def<nbsp/>b(skip)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>a(skip)</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>def<nbsp/>c(skip)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>b(skip)</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
  <td><tt>c(0)</tt></td>
  <td>&#187;</td>
  <td><tt>["prog:2:in<nbsp/>`a'",<nbsp/>"prog:5:in<nbsp/>`b'",<nbsp/>"prog:8:in<nbsp/>`c'",<nbsp/>"prog:10"]</tt></td>
</tr>
<tr>
  <td><tt>c(1)</tt></td>
  <td>&#187;</td>
  <td><tt>["prog:5:in<nbsp/>`b'",<nbsp/>"prog:8:in<nbsp/>`c'",<nbsp/>"prog:11"]</tt></td>
</tr>
<tr>
  <td><tt>c(2)</tt></td>
  <td>&#187;</td>
  <td><tt>["prog:8:in<nbsp/>`c'",<nbsp/>"prog:12"]</tt></td>
</tr>
<tr>
  <td><tt>c(3)</tt></td>
  <td>&#187;</td>
  <td><tt>["prog:13"]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="catch" ref="catch">
      <callseq>
        catch( <em>symbol</em> ) <block>{|  | <blockbody>block</blockbody> }</block>
<p/>
        <returns>anObject</returns>
      </callseq>
      <desc>
<p/>
            <meth>catch</meth> executes its block. If a <meth>throw</meth> is
      executed, Ruby searches up its stack for a <meth>catch</meth> block with a tag
      corresponding to the <meth>throw</meth>'s <em>symbol</em>. If found, that block is
      terminated, and <meth>catch</meth> returns the value given to
      <meth>throw</meth>.  If <meth>throw</meth> is not called,
      the block terminates normally, and
      the value of <tt>catch</tt> is the value of the last expression
      evaluated.  <meth>catch</meth> expressions may be nested, and the
      <meth>throw</meth> call need not be in lexical scope.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[      def routine(n)
        puts n
        throw :done if n <= 0
        routine(n-1)
      end

      catch(:done) { routine(3) }
]]></fullcode>
def<nbsp/>routine(n)
<nbsp/><nbsp/>puts<nbsp/>n
<nbsp/><nbsp/>throw<nbsp/>:done<nbsp/>if<nbsp/>n<nbsp/>&lt;=<nbsp/>0
<nbsp/><nbsp/>routine(n-1)
end
<p/>
catch(:done)<nbsp/>{<nbsp/>routine(3)<nbsp/>}
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
3
2
1
0
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="chomp" ref="chomp">
      <callseq>
        chomp( <opt><obj>aString</obj></opt> )
        <returns>$_ or <em>aString</em></returns>
      </callseq>
      <desc>
         Equivalent to
      <tt>$_ = $_.chomp(<em>aString</em>)</tt>.
      See <cim><file>string</file><front>String</front><back>chomp</back><mref>chomp</mref></cim>  on page 367.
<p/>
<codefragment>
<fullcode><![CDATA[         $_ = "now\n"
         chomp
         $_
         chomp "ow"
         $_
         chomp "xxx"
         $_
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>$_<nbsp/>=<nbsp/>"now\n"</tt></td>
</tr>
<tr>
  <td><tt>chomp</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>chomp<nbsp/>"ow"</tt></td>
  <td>&#187;</td>
  <td><tt>"n"</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"n"</tt></td>
</tr>
<tr>
  <td><tt>chomp<nbsp/>"xxx"</tt></td>
  <td>&#187;</td>
  <td><tt>"n"</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"n"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="chomp!" ref="chomp_oh">
      <callseq>
        chomp!( <opt><obj>aString</obj></opt> )
        <returns>$_ or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$_.chomp!(<em>aString</em>)</tt>.
      See <cim><file>string</file><front>String</front><back>chomp!</back><mref>chomp_oh</mref></cim>
<p/>
<codefragment>
<fullcode><![CDATA[         $_ = "now\n"
         chomp!
         $_
         chomp! "x"
         $_
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>$_<nbsp/>=<nbsp/>"now\n"</tt></td>
</tr>
<tr>
  <td><tt>chomp!</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>chomp!<nbsp/>"x"</tt></td>
  <td>&#187;</td>
  <td><tt>nil</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="chop" ref="chop">
      <callseq>
        chop <returns><em>aString</em></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to
      <tt>($_.dup).chop!</tt>, except <tt>nil</tt> is never
      returned.
      See <cim><file>string</file><front>String</front><back>chop!</back><mref>chop_oh</mref></cim> on page 367.
<p/>
<codefragment>
<fullcode><![CDATA[         a  =  "now\r\n"
         $_ = a
         chop
         $_
         chop
         chop
         chop
         chop
         a
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>a<nbsp/><nbsp/>=<nbsp/><nbsp/>"now\r\n"</tt></td>
</tr>
<tr>
<td colspan="3"><tt>$_<nbsp/>=<nbsp/>a</tt></td>
</tr>
<tr>
  <td><tt>chop</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>chop</tt></td>
  <td>&#187;</td>
  <td><tt>"no"</tt></td>
</tr>
<tr>
  <td><tt>chop</tt></td>
  <td>&#187;</td>
  <td><tt>"n"</tt></td>
</tr>
<tr>
  <td><tt>chop</tt></td>
  <td>&#187;</td>
  <td><tt>""</tt></td>
</tr>
<tr>
  <td><tt>chop</tt></td>
  <td>&#187;</td>
  <td><tt>""</tt></td>
</tr>
<tr>
  <td><tt>a</tt></td>
  <td>&#187;</td>
  <td><tt>"now\r\n"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="chop!" ref="chop_oh">
      <callseq>
        chop! <returns>$_ or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$_.chop!</tt>.
<p/>
<codefragment>
<fullcode><![CDATA[         a  = "now\r\n"
         $_ = a
         chop!
         chop!
         chop!
         chop!
         chop!
         $_
         a
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>a<nbsp/><nbsp/>=<nbsp/>"now\r\n"</tt></td>
</tr>
<tr>
<td colspan="3"><tt>$_<nbsp/>=<nbsp/>a</tt></td>
</tr>
<tr>
  <td><tt>chop!</tt></td>
  <td>&#187;</td>
  <td><tt>"now"</tt></td>
</tr>
<tr>
  <td><tt>chop!</tt></td>
  <td>&#187;</td>
  <td><tt>"no"</tt></td>
</tr>
<tr>
  <td><tt>chop!</tt></td>
  <td>&#187;</td>
  <td><tt>"n"</tt></td>
</tr>
<tr>
  <td><tt>chop!</tt></td>
  <td>&#187;</td>
  <td><tt>""</tt></td>
</tr>
<tr>
  <td><tt>chop!</tt></td>
  <td>&#187;</td>
  <td><tt>nil</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>""</tt></td>
</tr>
<tr>
  <td><tt>a</tt></td>
  <td>&#187;</td>
  <td><tt>""</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="eval" ref="eval">
      <callseq>
        eval( <em>aString</em>
        <opt>, <em>aBinding</em> <opt><em>file</em> <opt><em>line</em></opt></opt></opt>)
        <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
      Evaluates the Ruby expression(s) in <em>aString</em>. If
      <em>aBinding</em> is given, the evaluation is performed in its
      context.      
      The binding may be a <classname>Binding</classname> object or a <classname>Proc</classname> 
      object. If the optional <em>file</em> and <em>line</em> parameters
      are present, they will be used when reporting syntax errors.
<p/>
<codefragment>
<fullcode><![CDATA[      def getBinding(str)
        return binding
      end
      str = "hello"
      eval "str + ' Fred'"
      eval "str + ' Fred'", getBinding("bye")
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>def<nbsp/>getBinding(str)</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/>return<nbsp/>binding</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
<td colspan="3"><tt>str<nbsp/>=<nbsp/>"hello"</tt></td>
</tr>
<tr>
  <td><tt>eval<nbsp/>"str<nbsp/>+<nbsp/>'<nbsp/>Fred'"</tt></td>
  <td>&#187;</td>
  <td><tt>"hello<nbsp/>Fred"</tt></td>
</tr>
<tr>
  <td><tt>eval<nbsp/>"str<nbsp/>+<nbsp/>'<nbsp/>Fred'",<nbsp/>getBinding("bye")</tt></td>
  <td>&#187;</td>
  <td><tt>"bye<nbsp/>Fred"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="exec" ref="exec">
      <callseq>
        exec( <em>command</em> <opt>, <em>args</em></opt>)
      </callseq>
      <desc>
<p/>
            Replaces the current process by running the given external
      command.      
      If <meth>exec</meth> is given a single
      argument, that argument is taken as a line that is subject to
      shell expansion before being executed. If multiple arguments are
      given, the second and subsequent arguments are passed as
      parameters to <em>command</em> with no shell expansion. If the
      first argument is a two-element array, the first element is the
      command to be executed, and the second argument is used as the
      <tt>argv[0]</tt> value, which may show up in process listings. In MSDOS
      environments, the command is executed in a subshell; otherwise,
      one of the <tt>exec(2)</tt> system calls is used, so the running
      command may inherit some of the environment of the original
      program (including open file descriptors).
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         exec "echo *"       # echoes list of files in current directory
         # never get here

         exec "echo", "*"    # echoes an asterisk
         # never get here
]]></fullcode>
exec<nbsp/>"echo<nbsp/>*"<nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>echoes<nbsp/>list<nbsp/>of<nbsp/>files<nbsp/>in<nbsp/>current<nbsp/>directory
#<nbsp/>never<nbsp/>get<nbsp/>here
<p/>
exec<nbsp/>"echo",<nbsp/>"*"<nbsp/><nbsp/><nbsp/><nbsp/>#<nbsp/>echoes<nbsp/>an<nbsp/>asterisk
#<nbsp/>never<nbsp/>get<nbsp/>here
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="exit" ref="exit">
      <callseq>
        exit( <obj>anInteger</obj>=0 )
      </callseq>
      <desc>
<p/>
                  Initiates the termination of the Ruby script by raising the
      <exception>SystemExit</exception> exception. This exception may be caught. The
      optional parameter is used to return a status code to the
      invoking environment.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         begin
           exit
           puts "never get here"
         rescue SystemExit
           puts "rescued a SystemExit exception"
         end
         puts "after begin block"
]]></fullcode>
begin
<nbsp/><nbsp/>exit
<nbsp/><nbsp/>puts<nbsp/>"never<nbsp/>get<nbsp/>here"
rescue<nbsp/>SystemExit
<nbsp/><nbsp/>puts<nbsp/>"rescued<nbsp/>a<nbsp/>SystemExit<nbsp/>exception"
end
puts<nbsp/>"after<nbsp/>begin<nbsp/>block"
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
rescued<nbsp/>a<nbsp/>SystemExit<nbsp/>exception
after<nbsp/>begin<nbsp/>block
</alltt>
</codefragment>
<p/>
      Just prior to termination, Ruby executes
      any <tt>at_exit</tt> functions and runs any object finalizers (see
      <modulename>ObjectSpace</modulename> beginning on page 430).
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         at_exit { puts "at_exit function" }
         ObjectSpace.define_finalizer(self,  proc { puts "in finalizer" })
         exit
]]></fullcode>
at_exit<nbsp/>{<nbsp/>puts<nbsp/>"at_exit<nbsp/>function"<nbsp/>}
ObjectSpace.define_finalizer(self,<nbsp/><nbsp/>proc<nbsp/>{<nbsp/>puts<nbsp/>"in<nbsp/>finalizer"<nbsp/>})
exit
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
at_exit<nbsp/>function
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="exit!" ref="exit_oh">
      <callseq>
        exit!( <obj>anInteger</obj>=-1 )
      </callseq>
      <desc>
<p/>
      Similar to <mmm><file>kernel</file><front>Kernel</front><back>exit</back><mref>exit</mref></mmm>, but exception handling,
      <meth>at_exit</meth> functions, and finalizers are bypassed.
<p/>
      </desc>
    </method>
<p/>
        <method name="fail" ref="fail">
      <callseq>
                  fail<br/>fail( <obj>aString</obj> )<br/>fail( <obj>anException</obj> <opt>, <obj>aString</obj>
            <opt><obj>anArray</obj></opt></opt> )
      </callseq>
      <desc>
<p/>
      Synonym for <mmm><file>kernel</file><front>Kernel</front><back>raise</back><mref>raise</mref></mmm>.
<p/>
      </desc>
    </method>
<p/>
        <method name="fork" ref="fork">
      <callseq>
        fork <opt><block>{ <blockbody>block</blockbody> }</block>
</opt> <returns><obj>aFixnum</obj>
        or <tt>nil</tt></returns>
      </callseq>
      <desc>
                  Creates a subshell. If a block is specified, that block is run
      in the subshell, and the subshell terminates with a status of
      zero. Otherwise, the <meth>fork</meth> call returns twice, once in
      the parent, returning the  process id of the child, and once in
      the child, returning <tt>nil</tt>. The child process can
      exit using <mmm><file>kernel</file><front>Kernel</front><back>exit!</back><mref>exit_oh</mref></mmm> to avoid running any
      <meth>at_exit</meth> functions. The parent process should use
      <mmm><file>process</file><front>Process</front><back>wait</back><mref>wait</mref></mmm> to collect the termination statuses of its
      children; otherwise, the operating system may accumulate zombie
      processes.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[!-      $stdout.sync = true
      fork do
!-        3.times {|i| puts "Child: #{i}\n"; sleep .05 }
#        3.times {|i| puts "Child: #{i}" }
      end
!-      3.times {|i| puts "Parent: #{i}\n"; sleep .05 }
#      3.times {|i| puts "Parent: #{i}" }
      Process.wait
]]></fullcode>
fork<nbsp/>do
<nbsp/><nbsp/>3.times<nbsp/>{|i|<nbsp/>puts<nbsp/>"Child:<nbsp/>#{i}"<nbsp/>}
end
3.times<nbsp/>{|i|<nbsp/>puts<nbsp/>"Parent:<nbsp/>#{i}"<nbsp/>}
Process.wait
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
Parent:<nbsp/>0
Child:<nbsp/>0
Parent:<nbsp/>1
Child:<nbsp/>1
Parent:<nbsp/>2
Child:<nbsp/>2
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="format" ref="format">
      <callseq>
        format( <obj>aString</obj> <optz>,
          <obj>anObject</obj></optz> ) <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <mmm><file>kernel</file><front>Kernel</front><back>sprintf</back><mref>sprintf</mref></mmm>.
<p/>
      </desc>
    </method>
<p/>
        <method name="gets" ref="gets">
      <callseq>
        gets( <obj>aString</obj>=<var>$/</var> )
        <returns><obj>aString</obj> or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Returns (and assigns to <var>$_</var>) the next line from
      the list of files in <var>ARGV</var> (or <var>$*</var>), or
      from standard input if no files are present on the command line.
      Returns <tt>nil</tt> at end of file. 
      The optional argument specifies the
      record separator. The separator is
      included with the contents of each record. A separator of <tt>nil</tt>
      reads the entire contents, and a zero-length separator reads the
      input one paragraph at a time, where paragraphs are divided
      by two consecutive newlines. If multiple filenames are
      present in <var>ARGV</var>, <meth>gets(nil)</meth> will read the
      contents one file at a time.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        ARGV << "testfile"
        print while gets
]]></fullcode>
ARGV<nbsp/>&lt;&lt;<nbsp/>"testfile"
print<nbsp/>while<nbsp/>gets
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
This<nbsp/>is<nbsp/>line<nbsp/>one
This<nbsp/>is<nbsp/>line<nbsp/>two
This<nbsp/>is<nbsp/>line<nbsp/>three
And<nbsp/>so<nbsp/>on...
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="global_variables" ref="global_variables">
      <callseq>
        global_variables
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an array of the names of global variables.
<p/>
<codefragment>
<fullcode><![CDATA[        global_variables.grep /std/
]]></fullcode><rubycode>
<tr>
  <td><tt>global_variables.grep<nbsp/>/std/</tt></td>
  <td>&#187;</td>
  <td><tt>["$stdin",<nbsp/>"$stderr",<nbsp/>"$stdout"]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="gsub" ref="gsub">
      <callseq>
                    gsub( <obj>pattern</obj>, <obj>replacement</obj> )
          <returns><obj>aString</obj></returns><br/>gsub( <obj>pattern</obj> ) <block>{|  | <blockbody>block</blockbody> }</block>
<p/>
          <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$_.gsub...</tt>, except that <var>$_</var>
      receives the modified result.
<p/>
<codefragment>
<fullcode><![CDATA[        $_ = "quick brown fox"
        gsub /[aeiou]/, '*'
        $_
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>$_<nbsp/>=<nbsp/>"quick<nbsp/>brown<nbsp/>fox"</tt></td>
</tr>
<tr>
  <td><tt>gsub<nbsp/>/[aeiou]/,<nbsp/>'*'</tt></td>
  <td>&#187;</td>
  <td><tt>"q**ck<nbsp/>br*wn<nbsp/>f*x"</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"q**ck<nbsp/>br*wn<nbsp/>f*x"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="gsub!" ref="gsub_oh">
      <callseq>
                    gsub!( <obj>pattern</obj>, <obj>replacement</obj> )
          <returns><obj>aString</obj> or <tt>nil</tt></returns><br/>gsub!( <obj>pattern</obj> ) <block>{|  | <blockbody>block</blockbody> }</block>
<p/>
          <returns><obj>aString</obj> or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <mmm><file>kernel</file><front>Kernel</front><back>gsub</back><mref>gsub</mref></mmm>, except <tt>nil</tt> is returned if
      <var>$_</var> is not modified.
<p/>
<codefragment>
<fullcode><![CDATA[        $_ = "quick brown fox"
        gsub! /cat/, '*'
        $_
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>$_<nbsp/>=<nbsp/>"quick<nbsp/>brown<nbsp/>fox"</tt></td>
</tr>
<tr>
  <td><tt>gsub!<nbsp/>/cat/,<nbsp/>'*'</tt></td>
  <td>&#187;</td>
  <td><tt>nil</tt></td>
</tr>
<tr>
  <td><tt>$_</tt></td>
  <td>&#187;</td>
  <td><tt>"quick<nbsp/>brown<nbsp/>fox"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="iterator?" ref="iterator_qm">
      <callseq>
        iterator? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <mmm><file>kernel</file><front>Kernel</front><back>block_given?</back><mref>block_given_qm</mref></mmm>. The <meth>iterator?</meth>
      method will be removed in Ruby 1.8.
<p/>
      </desc>
    </method>
<p/>
        <method name="lambda" ref="lambda">
      <callseq>
        lambda <block>{|  | <blockbody>block</blockbody> }</block>
 <returns><obj>aProc</obj></returns>
      </callseq>
      <desc>
<p/>
      Synonym for <mmm><file>kernel</file><front>Kernel</front><back>proc</back><mref>proc</mref></mmm>.
<p/>
      </desc>
    </method>
<p/>
        <method name="load" ref="load">
      <callseq>
        load( <obj>aFileName</obj>,
        <obj>wrap</obj>=<const>false</const> ) <returns><const>true</const></returns>
      </callseq>
      <desc>
<p/>
            Loads and executes the Ruby program in the file
      <obj>aFileName</obj>. If the filename does not resolve to an absolute path, the
      file is searched for in the library directories listed in
      <var>$:</var>. If the optional <obj>wrap</obj> parameter is
      <const>true</const>, the loaded script will be executed under an
      anonymous module, protecting the calling program's global
      namespace. Any local variables in the loaded file will not be
      propagated to the loading environment.
<p/>
      </desc>
    </method>
<p/>
        <method name="local_variables" ref="local_variables">
      <callseq>
        local_variables
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the names of the current local variables.
<p/>
<codefragment>
<fullcode><![CDATA[      fred = 1
      for i in 1..10
         # ...
      end
      local_variables
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>fred<nbsp/>=<nbsp/>1</tt></td>
</tr>
<tr>
<td colspan="3"><tt>for<nbsp/>i<nbsp/>in<nbsp/>1..10</tt></td>
</tr>
<tr>
<td colspan="3"><tt><nbsp/><nbsp/><nbsp/>#<nbsp/>...</tt></td>
</tr>
<tr>
<td colspan="3"><tt>end</tt></td>
</tr>
<tr>
  <td><tt>local_variables</tt></td>
  <td>&#187;</td>
  <td><tt>["fred",<nbsp/>"i"]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="loop" ref="loop">
      <callseq>
        loop <block>{|  | <blockbody>block</blockbody> }</block>
<p/>
      </callseq>
      <desc>
<p/>
      Repeatedly executes the block. 
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        loop {
          print "Input: "
          break if !gets or $_ =~ /^[qQ]/
          # ...
        }
]]></fullcode>
loop<nbsp/>{
<nbsp/><nbsp/>print<nbsp/>"Input:<nbsp/>"
<nbsp/><nbsp/>break<nbsp/>if<nbsp/>!gets<nbsp/>or<nbsp/>$_<nbsp/>=~<nbsp/>/^qQ/
<nbsp/><nbsp/>#<nbsp/>...
}
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="open" ref="open">
      <callseq>
                  open( <obj>aString</obj>
                <opt>, <obj>aMode</obj> <opt><obj>perm</obj></opt></opt> )
                <returns><obj>anIO</obj> or <tt>nil</tt></returns><br/>open( <obj>aString</obj>
                <opt>, <obj>aMode</obj> <opt><obj>perm</obj></opt></opt> ) <block>{| anIO | <blockbody>block</blockbody> }</block>
<p/>
                <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
         Creates an <classname>IO</classname> object connected to the given stream, file, 
         or subprocess.                  
<p/>
         If <obj>aString</obj> does not start with a pipe character
         (``<tt>|</tt>''), treat it as the name of a file to open using the
         specified mode defaulting to ``<tt>r</tt>'' (see the table of
         valid modes on page 326). If a file is being
         created, its initial permissions may be set using the integer 
         third parameter.
<p/>
         If a block is specified, it will be invoked with the <classname>File</classname>
         object as a parameter, and the file will be automatically
         closed when the block terminates. The call always returns
         <tt>nil</tt> in this case.
<p/>
         If <obj>aString</obj> starts with a pipe character, a subprocess
         is created, connected to the caller by a pair of pipes. The
         returned <classname>IO</classname> object may be used to write to the standard
         input and read from the standard output of this subprocess.
         If the command following the ``<tt>|</tt>'' is a single minus sign,
         Ruby forks, and this subprocess is connected to the parent.
         In the subprocess, the <meth>open</meth> call returns <tt>nil</tt>. If
         the command is not ``<tt>-</tt>'', the subprocess runs the command. If 
         a block is associated with an <tt>open("|-")</tt> call, that
         block will be run twice---once in the parent and once in the
         child. The block parameter will be an <classname>IO</classname> object in the
         parent and <tt>nil</tt> in the child. The parent's <classname>IO</classname> object will
         be connected to the child's <tt>$stdin</tt> and <tt>$stdout</tt>.
         The subprocess will be terminated at the end of the
         block.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[           open("testfile") do |f|
             print f.gets
           end
]]></fullcode>
open("testfile")<nbsp/>do<nbsp/>|f|
<nbsp/><nbsp/>print<nbsp/>f.gets
end
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
This<nbsp/>is<nbsp/>line<nbsp/>one
</alltt>
</codefragment>
<p/>
         Open a subprocess and read its output:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         cmd = open("|date")
         print cmd.gets
         cmd.close
]]></fullcode>
cmd<nbsp/>=<nbsp/>open("|date")
print<nbsp/>cmd.gets
cmd.close
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
Sun<nbsp/>Jun<nbsp/><nbsp/>9<nbsp/>00:19:39<nbsp/>CDT<nbsp/>2002
</alltt>
</codefragment>
<p/>
         Open a subprocess running the same Ruby program:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         f = open("|-", "w+")
         if f == nil
           puts "in Child"
           exit
         else
           puts "Got: #{f.gets}"
         end
]]></fullcode>
f<nbsp/>=<nbsp/>open("|-",<nbsp/>"w+")
if<nbsp/>f<nbsp/>==<nbsp/>nil
<nbsp/><nbsp/>puts<nbsp/>"in<nbsp/>Child"
<nbsp/><nbsp/>exit
else
<nbsp/><nbsp/>puts<nbsp/>"Got:<nbsp/>#{f.gets}"
end
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
Got:<nbsp/>in<nbsp/>Child
</alltt>
</codefragment>
<p/>
         Open a subprocess using a block to receive the I/O object:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         open("|-") do |f|
           if f == nil
             puts "in Child"
           else
             puts "Got: #{f.gets}"
           end
         end
]]></fullcode>
open("|-")<nbsp/>do<nbsp/>|f|
<nbsp/><nbsp/>if<nbsp/>f<nbsp/>==<nbsp/>nil
<nbsp/><nbsp/><nbsp/><nbsp/>puts<nbsp/>"in<nbsp/>Child"
<nbsp/><nbsp/>else
<nbsp/><nbsp/><nbsp/><nbsp/>puts<nbsp/>"Got:<nbsp/>#{f.gets}"
<nbsp/><nbsp/>end
end
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
Got:<nbsp/>in<nbsp/>Child
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="p" ref="p">
      <callseq>
        p( <optn><obj>anObject</obj></optn> )
      <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      For each object, directly writes <tt><obj>anObject</obj>.inspect</tt> followed by
      the current output record separator to the program's standard
      output. <meth>p</meth> bypasses the Ruby I/O libraries.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         p self
]]></fullcode>
p<nbsp/>self
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
main
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="print" ref="print">
      <callseq>
        print( <optz><obj>anObject</obj></optz> )
        <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Prints each object in turn to <var>$defout</var>. If the
      output field separator (<var>$,</var>)
      is not <tt>nil</tt>, its contents will appear
      between each field.      
      If the output record separator
      (<var>$\</var>)
      is not <tt>nil</tt>, it will be appended to the output. If 
      no arguments are given, prints <var>$_</var>. Objects that aren't
      strings will be converted by calling their <meth>to_s</meth>      
      method.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        print "cat", [1,2,3], 99, "\n"
        $, = ", "
        $\ = "\n"
        print "cat", [1,2,3], 99
]]></fullcode>
print<nbsp/>"cat",<nbsp/>[1,2,3],<nbsp/>99,<nbsp/>"\n"
$,<nbsp/>=<nbsp/>",<nbsp/>"
$\<nbsp/>=<nbsp/>"\n"
print<nbsp/>"cat",<nbsp/>[1,2,3],<nbsp/>99
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
cat12399
cat,<nbsp/>1,<nbsp/>2,<nbsp/>3,<nbsp/>99
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="printf" ref="printf">
      <callseq>
                  printf( <obj>anIO</obj>, <obj>aString</obj> <optz>, <obj>anObject</obj></optz> )
          <returns><tt>nil</tt></returns><br/>printf( <obj>aString</obj> <optz>, <obj>anObject</obj></optz> )
          <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
              Equivalent to:
<p/>
<obj>anIO.</obj><tt>write sprintf(</tt><obj>aString,<nbsp/>anObject</obj><tt> ...)</tt><br/><em>or</em><br/><tt>$defout.write sprintf(</tt><obj>aString,<nbsp/>anObject</obj><tt> ...)</tt>
<p/>
      </desc>
    </method>
<p/>
        <method name="proc" ref="proc">
      <callseq>
        proc <block>{ <blockbody>block</blockbody> }</block>
<returns><obj>aProc</obj></returns>
      </callseq>
      <desc>
<p/>
      Creates a new procedure object from the given block. Equivalent
      to <ccm><file>proc</file><front>Proc</front><back>new</back><mref>new</mref></ccm>.
<p/>
<codefragment>
<fullcode><![CDATA[        aProc = proc { "hello" }
        aProc.call
]]></fullcode><rubycode>
<tr>
<td colspan="3"><tt>aProc<nbsp/>=<nbsp/>proc<nbsp/>{<nbsp/>"hello"<nbsp/>}</tt></td>
</tr>
<tr>
  <td><tt>aProc.call</tt></td>
  <td>&#187;</td>
  <td><tt>"hello"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="putc" ref="putc">
      <callseq>
        putc( <obj>anInteger</obj> ) <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$defout.putc(</tt><obj>anInteger</obj><tt>)</tt>.
<p/>
      </desc>
    </method>
<p/>
        <method name="puts" ref="puts">
      <callseq>
        puts( <optz><obj>args</obj></optz> ) <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$defout.puts(</tt><obj>args</obj><tt>)</tt>.
<p/>
      </desc>
    </method>
<p/>
        <method name="raise" ref="raise">
      <callseq>
                  raise<br/>raise( <obj>aString</obj> )<br/>raise( <obj>anException</obj> <opt>, <obj>aString</obj>
            <opt><obj>anArray</obj></opt></opt> )
      </callseq>
      <desc>
<p/>
            With no arguments, raises the
      exception in <var>$!</var> or raises a
      <exception>RuntimeError</exception> if <var>$!</var> is <tt>nil</tt>.      
      With a single <classname>String</classname> argument, raises a
      <exception>RuntimeError</exception> with the string as a message. Otherwise, the
      first parameter should be the name of an <exception>Exception</exception> class
      (or an object that returns an <exception>Exception</exception> when sent
      <meth>exception</meth>). The
      optional second parameter sets the message associated with the
      exception, and the third parameter is an array of callback
      information. Exceptions are caught by the <tt>rescue</tt> clause of
      <tt>begin...end</tt> blocks.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        raise "Failed to create socket"
        raise ArgumentError, "No parameters", caller
]]></fullcode>
raise<nbsp/>"Failed<nbsp/>to<nbsp/>create<nbsp/>socket"
raise<nbsp/>ArgumentError,<nbsp/>"No<nbsp/>parameters",<nbsp/>caller
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="rand" ref="rand">
      <callseq>
        rand( <obj>max</obj>=0 )
        <returns><obj>aNumber</obj></returns>
      </callseq>
      <desc>
              Converts <obj>max</obj> to an integer using max<sub>1</sub> =
      max<tt>.to_i.abs</tt>.
      If the result is zero, returns a pseudorandom floating point
      number greater than or equal to 0.0 and less than
      1.0. Otherwise, returns a pseudorandom integer greater than or
      equal to zero and less than max<sub>1</sub>. <mmm><file>kernel</file><front>Kernel</front><back>srand</back><mref>srand</mref></mmm> may be
      used to ensure repeatable sequences of random numbers between
      different runs of the program.
<p/>
<codefragment>
<fullcode><![CDATA[        srand 1234
        [ rand,  rand ]
        [ rand(10), rand(1000) ]
        srand 1234
        [ rand,  rand ]
]]></fullcode><rubycode>
<tr>
  <td><tt>srand<nbsp/>1234</tt></td>
  <td>&#187;</td>
  <td><tt>0</tt></td>
</tr>
<tr>
  <td><tt>[<nbsp/>rand,<nbsp/><nbsp/>rand<nbsp/>]</tt></td>
  <td>&#187;</td>
  <td><tt>[0.7408769294,<nbsp/>0.2145348572]</tt></td>
</tr>
<tr>
  <td><tt>[<nbsp/>rand(10),<nbsp/>rand(1000)<nbsp/>]</tt></td>
  <td>&#187;</td>
  <td><tt>[3,<nbsp/>323]</tt></td>
</tr>
<tr>
  <td><tt>srand<nbsp/>1234</tt></td>
  <td>&#187;</td>
  <td><tt>1234</tt></td>
</tr>
<tr>
  <td><tt>[<nbsp/>rand,<nbsp/><nbsp/>rand<nbsp/>]</tt></td>
  <td>&#187;</td>
  <td><tt>[0.7408769294,<nbsp/>0.2145348572]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="readline" ref="readline">
      <callseq>
        readline( <opt><obj>aString</obj>=<var>$/</var></opt> )
        <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <mmm><file>kernel</file><front>Kernel</front><back>gets</back><mref>gets</mref></mmm>, except <meth>readline</meth> raises 
      <exception>EOFError</exception> at end of file.
<p/>
      </desc>
    </method>
<p/>
        <method name="readlines" ref="readlines">
      <callseq>
        readlines( <opt><obj>aString</obj>=<var>$/</var></opt> )
        <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns an array containing the lines returned by
      calling <tt>Kernel.gets(<obj>aString</obj>)</tt> until the end of file.
<p/>
      </desc>
    </method>
<p/>
        <method name="require" ref="require">
      <callseq>
        require( <obj>aString</obj> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
              Ruby tries to load the library named <obj>aString</obj>, returning
      <const>true</const> if successful. If the filename does not resolve to an
      absolute path, it will be searched for in the directories listed 
      in <var>$:</var>. If the file has the extension
      ``.rb'', it is loaded as a source file; if the extension is
      ``.so'', ``.o'', or ``.dll'',<footnote>Or whatever the default
        shared library extension is on the current platform.</footnote> Ruby
      loads the shared library as a Ruby extension. Otherwise, Ruby
      tries adding ``.rb'', ``.so'', and so on to the name. The name
      of the loaded feature is added to the array in <var>$"</var>. A
      feature will not be loaded if it already appears in <var>$"</var>.
      <meth>require</meth> returns <const>true</const> if the feature was
      successfully loaded.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        require "my-library.rb"
        require "db-driver"
]]></fullcode>
require<nbsp/>"my-library.rb"
require<nbsp/>"db-driver"
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="scan" ref="scan">
      <callseq>
                  scan( <obj>pattern</obj> ) <returns><obj>anArray</obj></returns><br/>scan( <obj>pattern</obj> ) <block>{|  | <blockbody>block</blockbody> }</block>
 <returns>$_</returns>
      </callseq>
      <desc>
<p/>
      Equivalent to calling <tt>$_.scan</tt>. See <cim><file>string</file><front>String</front><back>scan</back><mref>scan</mref></cim>
      on page 373.
<p/>
      </desc>
    </method>
<p/>
        <method name="select" ref="select">
      <callseq>
        select( <obj>readArray</obj> <opt>,
          <obj>writeArray</obj>
          <opt><obj>errorArray</obj> <opt><obj>timeout</obj></opt></opt></opt> )
        <returns><obj>anArray</obj> or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Performs
      a low-level <tt>select</tt> call, which waits for data to
      become available from input/output devices. The first three
      parameters are arrays of <classname>IO</classname> objects or <tt>nil</tt>. The last is a
      timeout in seconds, which should be an <classname>Integer</classname> or a
      <classname>Float</classname>.  The call waits for data to become available for any
      of the <classname>IO</classname> objects in <obj>readArray</obj>, for buffers to have
      cleared sufficiently to enable writing to any of the devices in
      <obj>writeArray</obj>, or for an error to occur on the devices in
      <obj>errorArray</obj>. If one or more of these conditions are met, the
      call returns a three-element array containing arrays of the
      <classname>IO</classname> objects that were ready.  Otherwise, if there is no
      change in status for <obj>timeout</obj> seconds, the call returns
      <tt>nil</tt>. If all parameters are <tt>nil</tt>, the current thread sleeps forever.
<p/>
<codefragment>
<fullcode><![CDATA[         select( [$stdin], nil, nil, 1.5 )
]]></fullcode><rubycode>
<tr>
  <td><tt>select(<nbsp/>[$stdin],<nbsp/>nil,<nbsp/>nil,<nbsp/>1.5<nbsp/>)</tt></td>
  <td>&#187;</td>
  <td><tt>[[#&lt;IO:0x401ba090&gt;],<nbsp/>[],<nbsp/>[]]</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="set_trace_func" ref="set_trace_func">
      <callseq>
                set_trace_func( <obj>aProc</obj> ) <returns><obj>aProc</obj></returns><br/>set_trace_func( <tt>nil</tt> ) <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
              Establishes <obj>aProc</obj> as the handler for tracing, or disables
      tracing if the parameter is <tt>nil</tt>. <obj>aProc</obj>
      takes up to six parameters: an event name, a filename, a line
      number, an object id, a binding, and the name of a
      class. <obj>aProc</obj> is invoked whenever an event
      occurs. Events are:
      <tt>c-call</tt> (call a C-language routine),
      <tt>c-return</tt> (return from a C-language routine),
      <tt>call</tt> (call a Ruby method),
      <tt>class</tt> (start a class or module definition),
      <tt>end</tt> (finish a class or module definition),
      <tt>line</tt> (execute code on a new line),
      <tt>raise</tt> (raise an exception), and
      <tt>return</tt> (return from a Ruby method).
      Tracing is disabled within the context of <obj>aProc</obj>.
<p/>
      See the example starting on page 267 for more
      information.
<p/>
      </desc>
    </method>
<p/>
        <method name="singleton_method_added" ref="singleton_method_added">
      <callseq>
                singleton_method_added( <obj>aFixnum</obj> ) <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Invoked with a symbol id whenever a singleton method is added to 
      a module or a class. The default implementation in <modulename>Kernel</modulename>
      ignores this, but subclasses may override the method to provide
      specialized functionality.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[      class Test
        def Test.singleton_method_added(id)
          puts "Added #{id.id2name} to Test"
        end
        def a() end
        def Test.b() end
      end
      def Test.c() end
]]></fullcode>
class<nbsp/>Test
<nbsp/><nbsp/>def<nbsp/>Test.singleton_method_added(id)
<nbsp/><nbsp/><nbsp/><nbsp/>puts<nbsp/>"Added<nbsp/>#{id.id2name}<nbsp/>to<nbsp/>Test"
<nbsp/><nbsp/>end
<nbsp/><nbsp/>def<nbsp/>a()<nbsp/>end
<nbsp/><nbsp/>def<nbsp/>Test.b()<nbsp/>end
end
def<nbsp/>Test.c()<nbsp/>end
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
Added<nbsp/>singleton_method_added<nbsp/>to<nbsp/>Test
Added<nbsp/>b<nbsp/>to<nbsp/>Test
Added<nbsp/>c<nbsp/>to<nbsp/>Test
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="sleep" ref="sleep">
      <callseq>
        sleep( <opt><obj>aNumeric</obj></opt> )
        <returns><obj>aFixnum</obj></returns>
      </callseq>
      <desc>
<p/>
      Suspends the current thread for <obj>aNumber</obj> seconds (which may be a <classname>Float</classname>
      with fractional seconds). Returns the actual number of seconds
      slept (rounded), which may be less than that asked for if the
      thread was interrupted by a
      <tt>SIGALRM</tt>, or if another thread
      calls <cim><file>thread</file><front>Thread</front><back>run</back><mref>run</mref></cim>. An argument of zero causes <meth>sleep</meth>
      to sleep forever.
<p/>
<codefragment>
<fullcode><![CDATA[        Time.new
        sleep 1.2
        Time.new
        sleep 1.9
        Time.new
]]></fullcode><rubycode>
<tr>
  <td><tt>Time.new</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:40<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>sleep<nbsp/>1.2</tt></td>
  <td>&#187;</td>
  <td><tt>1</tt></td>
</tr>
<tr>
  <td><tt>Time.new</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:41<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
<tr>
  <td><tt>sleep<nbsp/>1.9</tt></td>
  <td>&#187;</td>
  <td><tt>2</tt></td>
</tr>
<tr>
  <td><tt>Time.new</tt></td>
  <td>&#187;</td>
  <td><tt>Sun<nbsp/>Jun<nbsp/>09<nbsp/>00:19:43<nbsp/>CDT<nbsp/>2002</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="split" ref="split">
      <callseq>
        split( <opt><obj>pattern</obj>
          <opt><obj>limit</obj></opt></opt> ) <returns><obj>anArray</obj></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to
      <tt>$_.split(<obj>pattern</obj>, <obj>limit</obj>)</tt>. See <cim><file>string</file><front>String</front><back>split</back><mref>split</mref></cim>
      on page 374.
<p/>
      </desc>
    </method>
<p/>
        <method name="sprintf" ref="sprintf">
      <callseq>
        sprintf( <obj>aFormatString</obj> 
                <optz>, <obj>arguments</obj></optz> ) <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the string resulting
      from applying <nbsp/><obj>aFormatString</obj> to any additional arguments.
      Within the format string, any characters other than format
      sequences are copied to the result.
      A format sequence consists of a percent sign, followed by
      optional flags, width, and precision indicators, then terminated
      with a field type character. The field type controls how the
      corresponding <meth>sprintf</meth> argument is to be interpreted,
      while the flags modify that interpretation.
      The flag characters are shown in Table
      23.1 on page 424, and the field type characters are listed 
      in Table 23.2.
<p/>
      The field width is an optional integer, followed optionally by a 
      period and a precision. The width specifies the minimum number
      of characters that will be written to the result for this
      field. For numeric fields, the precision controls the number of
      decimal places displayed. For string fields, the precision
      determines the maximum number of characters to be copied from
      the string. (Thus, the format sequence <tt>%10.10s</tt> will always 
      contribute exactly ten characters to the result.)
<p/>
      <figure type="table">
        <caption><meth>sprintf</meth> flag characters</caption>        
        <table>
<th>
  <td><b>Flag</b></td>
  <td><b>Applies to</b></td>
  <td><b>Meaning</b></td>
</th>
<tr>
  <td><tt><visible_space/></tt> (space)</td>
  <td>bdeEfgGioxXu</td>
  <td>Leave a
          space at the start of positive numbers.</td>
</tr>
<tr>
  <td><tt>#</tt></td>
  <td>beEfgGoxX</td>
  <td>Use an alternative format. For the
          conversions `o', `x', `X', and `b', prefix the result with
          ``0'', ``0x'', ``0X'', and ``0b'', respectively. For `e',
          `E', `f', `g', and 'G', force a decimal point to be added,
          even if no digits follow. For `g' and 'G', do not remove
          trailing zeros.</td>
</tr>
<tr>
  <td><tt>+</tt></td>
  <td>bdeEfgGioxXu</td>
  <td>Add a leading plus sign to
          positive numbers.</td>
</tr>
<tr>
  <td><tt>-</tt></td>
  <td>all</td>
  <td>Left-justify the result of this conversion.</td>
</tr>
<tr>
  <td><tt>0</tt> (zero)</td>
  <td>all</td>
  <td>Pad with zeros, not spaces.</td>
</tr>
<tr>
  <td><tt>*</tt></td>
  <td>all</td>
  <td>Use the next argument as the field width. If
          negative, left-justify the result. If the asterisk is
          followed by a number and a dollar sign, use 
          the indicated argument as the width.</td>
</tr>
<bottomrule/></table>
<p/>
      </figure>
<p/>
      <figure type="table">
        <caption><meth>sprintf</meth> field types</caption>        
        <table>
<th>
  <td><b>Field</b></td>
  <td><b>Conversion</b></td>
</th>
<tr>
  <td>b</td>
  <td>Convert argument as a binary number.</td>
</tr>
<tr>
  <td>c</td>
  <td>Argument is the numeric code for a single character.</td>
</tr>
<tr>
  <td>d</td>
  <td>Convert argument as a decimal number.</td>
</tr>
<tr>
  <td>E</td>
  <td>Equivalent to `e', but uses an uppercase E to indicate
          the exponent.</td>
</tr>
<tr>
  <td>e</td>
  <td>Convert floating point argument into exponential notation 
          with one digit before the decimal point. The precision
          determines the number of fractional digits (defaulting to six).</td>
</tr>
<tr>
  <td>f</td>
  <td>Convert floating point argument as <tt>[<visible_space/>-]ddd.ddd</tt>, 
          where the precision determines the number of digits after
          the decimal point.</td>
</tr>
<tr>
  <td>G</td>
  <td>Equivalent to `g', but use an uppercase `E' in exponent 
          form.</td>
</tr>
<tr>
  <td>g</td>
  <td>Convert a floating point number using exponential form
          if the exponent is less than -4 or greater than or
          equal to the precision, or in <tt>d.dddd</tt> form otherwise.</td>
</tr>
<tr>
  <td>i</td>
  <td>Identical to `d'.</td>
</tr>
<tr>
  <td>o</td>
  <td>Convert argument as an octal number.</td>
</tr>
<tr>
  <td>s</td>
  <td>Argument is a string to be substituted. If the format
          sequence contains a precision, at most that many characters
          will be copied.</td>
</tr>
<tr>
  <td>u</td>
  <td>Treat argument as an unsigned decimal number.</td>
</tr>
<tr>
  <td>X</td>
  <td>Convert argument as a hexadecimal number using uppercase letters.</td>
</tr>
<tr>
  <td>x</td>
  <td>Convert argument as a hexadecimal number.</td>
</tr>
<bottomrule/></table>
<p/>
      </figure>
<p/>
<codefragment>
<fullcode><![CDATA[        sprintf("%d %04x", 123, 123)
        sprintf("%08b '%4s'", 123, 123)
        sprintf("%*2$s %d", "hello", 10)
        sprintf("%*2$s %d", "hello", -10)
        sprintf("%+g:% g:%-g", 1.23, 1.23, 1.23)
]]></fullcode><rubycode>
<tr>
  <td><tt>sprintf("%d<nbsp/>%04x",<nbsp/>123,<nbsp/>123)</tt></td>
  <td>&#187;</td>
  <td><tt>"123<visible_space/>007b"</tt></td>
</tr>
<tr>
  <td><tt>sprintf("%08b<nbsp/>'%4s'",<nbsp/>123,<nbsp/>123)</tt></td>
  <td>&#187;</td>
  <td><tt>"01111011<visible_space/>'<visible_space/>123'"</tt></td>
</tr>
<tr>
  <td><tt>sprintf("%*2$s<nbsp/>%d",<nbsp/>"hello",<nbsp/>10)</tt></td>
  <td>&#187;</td>
  <td><tt>"<visible_space/><visible_space/><visible_space/><visible_space/><visible_space/>hello<visible_space/>10"</tt></td>
</tr>
<tr>
  <td><tt>sprintf("%*2$s<nbsp/>%d",<nbsp/>"hello",<nbsp/>-10)</tt></td>
  <td>&#187;</td>
  <td><tt>"hello<visible_space/><visible_space/><visible_space/><visible_space/><visible_space/><visible_space/>-10"</tt></td>
</tr>
<tr>
  <td><tt>sprintf("%+g:%<nbsp/>g:%-g",<nbsp/>1.23,<nbsp/>1.23,<nbsp/>1.23)</tt></td>
  <td>&#187;</td>
  <td><tt>"+1.23:<visible_space/>1.23:1.23"</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="srand" ref="srand">
      <callseq>
        srand( <opt><obj>aNumber</obj></opt> )
        <returns><obj>oldSeed</obj></returns>
      </callseq>
      <desc>
<p/>
      Seeds the pseudorandom number generator to the value of
      <obj>aNumber</obj>.<meth>to_i.abs</meth>. If <obj>aNumber</obj> is omitted or zero,
      seeds the generator using a combination of the time, the process 
      id, and a sequence number. (This is also the behavior if
      <mmm><file>kernel</file><front>Kernel</front><back>rand</back><mref>rand</mref></mmm> is called without previously calling
      <meth>srand</meth>, but without the sequence.)
      By setting the seed to a known value, scripts can be made
      deterministic during testing. The previous seed value is
      returned. Also see <mmm><file>kernel</file><front>Kernel</front><back>rand</back><mref>rand</mref></mmm> on page 421.
<p/>
      </desc>
    </method>
<p/>
        <method name="sub" ref="sub">
      <callseq>
                    sub( <obj>pattern</obj>, <obj>replacement</obj> )
            <returns>$_</returns><br/>sub( <obj>pattern</obj> ) { <obj>block</obj> }
            <returns>$_</returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$_.sub(<obj>args</obj>)</tt>, except that <var>$_</var> 
      will be updated if substitution occurs.
<p/>
      </desc>
    </method>
<p/>
        <method name="sub!" ref="sub_oh">
      <callseq>
                    sub!( <obj>pattern</obj>, <obj>replacement</obj> )
            <returns>$_ or <tt>nil</tt></returns><br/>sub!( <obj>pattern</obj> ) { <obj>block</obj> }
            <returns>$_ or <tt>nil</tt></returns>
      </callseq>
      <desc>
<p/>
      Equivalent to <tt>$_.sub!(<obj>args</obj>)</tt>.
<p/>
      </desc>
    </method>
<p/>
        <method name="syscall" ref="syscall">
      <callseq>
        syscall( <obj>aFixnum</obj>
        <optz>, <obj>args</obj></optz> )
        <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Calls the operating system function identified by <obj>aFixnum</obj>, 
      passing in the arguments, which must be either <classname>String</classname> objects, or
      <classname>Integer</classname> objects that ultimately fit within a native <tt>long</tt>. 
      Up to nine parameters may be passed (14 on the
      Atari-ST). The function identified
      by <obj>Fixnum</obj> is system dependent. On some Unix systems, the
      numbers may be obtained from a header file called
      <tt>syscall.h</tt>.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[           syscall 4, 1, "hello\n", 6   # '4' is write(2) on our box
]]></fullcode>
syscall<nbsp/>4,<nbsp/>1,<nbsp/>"hello\n",<nbsp/>6<nbsp/><nbsp/><nbsp/>#<nbsp/>'4'<nbsp/>is<nbsp/>write(2)<nbsp/>on<nbsp/>our<nbsp/>box
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
hello
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="system" ref="system">
      <callseq>
        system( <obj>aCmd</obj> <optz>, <obj>args</obj></optz> )
        <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Executes <obj>aCmd</obj> in a subshell, returning <const>true</const> if the 
      command was found and ran successfully, <const>false</const>
      otherwise. A detailed error code is available in <var>$?</var>. The 
      arguments are processed in the same way as for <mmm><file>kernel</file><front>Kernel</front><back>exec</back><mref>exec</mref></mmm>
      on page 415.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[!-        Dir.chdir("testdir")
        system("echo *")
        system("echo", "*")
]]></fullcode>
system("echo<nbsp/>*")
system("echo",<nbsp/>"*")
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
config.h<nbsp/>main.rb
*
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="test" ref="test">
      <callseq>
        test(<obj>aCmd</obj>, <obj>file1</obj> <opt>, <obj>file2</obj></opt> )
        <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
            Uses the integer <obj>aCmd</obj> to perform various tests on
      <obj>file1</obj> (Table 23.3 on page 426) or on <obj>file1</obj> and
      <obj>file2</obj> (Table 23.4).      
      <figure type="table">
                <caption>File tests with a single argument</caption>
        <table>
<th>
  <td><b>Integer</b></td>
  <td><b>Description</b></td>
  <td><b>Returns</b></td>
</th>
<tr>
  <td>?A</td>
  <td>Last access time for <obj>file1</obj></td>
  <td>Time</td>
</tr>
<tr>
  <td>?b</td>
  <td>True if <obj>file1</obj> is a block device</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?c</td>
  <td>True if <obj>file1</obj> is a character device</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?C</td>
  <td>Last change time for <obj>file1</obj></td>
  <td>Time</td>
</tr>
<tr>
  <td>?d</td>
  <td>True if <obj>file1</obj> exists and is a directory</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?e</td>
  <td>True if <obj>file1</obj> exists</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?f</td>
  <td>True if <obj>file1</obj> exists and is a regular file</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?g</td>
  <td>True if <obj>file1</obj> has the <tt>setgid</tt> bit set (false under
          NT)</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?G</td>
  <td>True if <obj>file1</obj> exists and has a group ownership equal to
          the caller's group</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?k</td>
  <td>True if <obj>file1</obj> exists and has the sticky bit set</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?l</td>
  <td>True if <obj>file1</obj> exists and is a symbolic link</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?M</td>
  <td>Last modification time for <obj>file1</obj></td>
  <td>Time</td>
</tr>
<tr>
  <td>?o</td>
  <td>True if <obj>file1</obj> exists and is owned by the caller's
          effective uid</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?O</td>
  <td>True if <obj>file1</obj> exists and is owned by the caller's
          real uid</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?p</td>
  <td>True if <obj>file1</obj> exists and is a fifo</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?r</td>
  <td>True if file is readable by the effective uid/gid of the
          caller</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?R</td>
  <td>True if file is readable by the real uid/gid of the
          caller</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?s</td>
  <td>If <obj>file1</obj> has nonzero size, return the size, otherwise
          return <tt>nil</tt></td>
  <td>Integer or <tt>nil</tt></td>
</tr>
<tr>
  <td>?S</td>
  <td>True if <obj>file1</obj> exists and is a socket</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?u</td>
  <td>True if <obj>file1</obj> has the setuid bit set</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?w</td>
  <td>True if <obj>file1</obj> exists and is writable by the effective
          uid/gid</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?W</td>
  <td>True if <obj>file1</obj> exists and is writable by the real
          uid/gid</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?x</td>
  <td>True if <obj>file1</obj> exists and is executable by the effective
          uid/gid</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?X</td>
  <td>True if <obj>file1</obj> exists and is executable by the real
          uid/gid</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<tr>
  <td>?z</td>
  <td>True if <obj>file1</obj> exists and has a zero length</td>
  <td><const>true</const> or <const>false</const></td>
</tr>
<bottomrule/></table>
<p/>
      </figure>
<p/>
      <figure type="table">
                        <caption>File tests with two arguments</caption>
        <table>
<th>
  <td><b>Integer</b></td>
  <td><b>Description</b></td>
</th>
<tr>
  <td>?-</td>
  <td>True if <obj>file1</obj> is a hard link to <obj>file2</obj></td>
</tr>
<tr>
  <td>?=</td>
  <td>True if the modification times of <obj>file1</obj> and <obj>file2</obj> are
          equal</td>
</tr>
<tr>
  <td>?&lt;</td>
  <td>True if the modification time of <obj>file1</obj> is prior to that
          of <obj>file2</obj></td>
</tr>
<tr>
  <td>?&gt;</td>
  <td>True if the modification time of <obj>file1</obj> is after that
          of <obj>file2</obj></td>
</tr>
<bottomrule/></table>
<p/>
      </figure>
<p/>
      </desc>
    </method>
<p/>
        <method name="throw" ref="throw">
      <callseq>
        throw( <obj>aSymbol</obj>
        <opt>, <obj>anObject</obj></opt> )
      </callseq>
      <desc>
<p/>
      Transfers control to the end of the active <meth>catch</meth> block
      waiting for <obj>aSymbol</obj>. Raises <exception>NameError</exception> if
      there is no <meth>catch</meth> block
      for the symbol. The optional second
      parameter supplies a return value for the <meth>catch</meth> block,
      which otherwise defaults to <tt>nil</tt>. For examples, see
      <mmm><file>kernel</file><front>Kernel</front><back>catch</back><mref>catch</mref></mmm> on page 413.
<p/>
      </desc>
    </method>
<p/>
        <method name="trace_var" ref="trace_var">
      <callseq>
                  trace_var( <obj>aSymbol</obj>, <obj>aCmd</obj> ) <returns><tt>nil</tt></returns><br/>trace_var( <obj>aSymbol</obj> ) <block>{| val | <blockbody>block</blockbody> }</block>
<p/>
          <returns><tt>nil</tt></returns>
      </callseq>
      <desc>
              Controls tracing of assignments to global variables. The
      parameter <obj>aSymbol</obj> identifies the variable (as either a
      string name or a symbol identifier).
      <obj>cmd</obj> (which may be a string or a <classname>Proc</classname> object) or block
      is executed whenever the variable is assigned. The block or
      <classname>Proc</classname> object receives the variable's new value as a
      parameter. Also see <mmm><file>kernel</file><front>Kernel</front><back>untrace_var</back><mref>untrace_var</mref></mmm>.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         trace_var :$_, proc {|v| puts "$_ is now '#{v}'" }
         $_ = "hello"
         $_ = ' there'
]]></fullcode>
trace_var<nbsp/>:$_,<nbsp/>proc<nbsp/>{|v|<nbsp/>puts<nbsp/>"$_<nbsp/>is<nbsp/>now<nbsp/>'#{v}'"<nbsp/>}
$_<nbsp/>=<nbsp/>"hello"
$_<nbsp/>=<nbsp/>'<nbsp/>there'
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
$_<nbsp/>is<nbsp/>now<nbsp/>'hello'
$_<nbsp/>is<nbsp/>now<nbsp/>'<nbsp/>there'
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="trap" ref="trap">
      <callseq>
                  trap( <obj>signal</obj>, <obj>cmd</obj> ) <returns><obj>anObject</obj></returns><br/>trap( <obj>signal</obj> ) <block>{|  | <blockbody>block</blockbody> }</block>
 <returns><obj>anObject</obj></returns>
      </callseq>
      <desc>
<p/>
            Specifies the handling of signals. The first parameter is a
      signal name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on)
      or a signal number. The characters ``SIG'' may be omitted from
      the signal name. The command or block specifies code to be run
      when the signal is raised. If the command is the string
      ``IGNORE'' or ``SIG_IGN'', the signal will be ignored. If the
      command is ``DEFAULT'' or ``SIG_DFL'', the operating system's
      default handler will be invoked. If the command is ``EXIT'', the 
      script will be terminated by the signal. Otherwise, the given
      command or block will be run.
<p/>
      The special signal name ``EXIT'' or signal
      number zero will be invoked just prior to program termination.
<p/>
      <meth>trap</meth> returns the previous handler for the given signal.
<p/>
<codefragment>
<alltt><fullcode><![CDATA[         trap 0, proc { puts "Terminating: #{$$}" }
         trap("CLD") { puts "Child died" }
         fork && Process.wait
]]></fullcode>
trap<nbsp/>0,<nbsp/>proc<nbsp/>{<nbsp/>puts<nbsp/>"Terminating:<nbsp/>#{$$}"<nbsp/>}
trap("CLD")<nbsp/>{<nbsp/>puts<nbsp/>"Child<nbsp/>died"<nbsp/>}
fork<nbsp/>&amp;&amp;<nbsp/>Process.wait
</alltt>
</codefragment>
<em>produces:</em>
<codefragment><alltt>
Terminating:<nbsp/>1425
Child<nbsp/>died
Terminating:<nbsp/>1424
</alltt>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="untrace_var" ref="untrace_var">
      <callseq>
        untrace_var( <obj>aSymbol</obj> <opt>,
          <obj>aCmd</obj></opt> ) <returns><obj>anArray</obj> or <tt>nil</tt></returns>
      </callseq>
      <desc>
         Removes tracing
      for the specified command on the given global variable and
      returns <tt>nil</tt>. If no command is specified, removes all tracing for
      that variable and returns an array containing the commands
      actually removed.
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
</class>
</ppdoc>
