📄 6.2.htm
字号:
("<TT><I>xx"</I></TT><TT>*2</TT>).<TT>to_i</TT>. </P>
<LI>
<P class=docList><TT>break</TT> and <TT>next</TT> extended
to take an optional expression, which is used as a return
value of the iterating method and <TT>yield</TT>,
respectively. </P>
<LI>
<P class=docList><A name=IXT-6-128967></A>The following new
methods (or modifications to methods) have been added: </P>
<DL class=docList>
<DT><TT>Array#fetch</TT>
<DT><TT>Array#insert</TT>
<DT><TT>Enumerable#all?</TT>
<DT><TT>Enumerable#any?</TT>
<DT><TT>Enumerable#inject</TT>
<DT><TT>Enumerable#sort_by</TT>
<DT><TT>File#fnmatch</TT>
<DT><TT>MatchData#to_ary</TT>
<DT><TT>Method#==</TT>
<DT><TT>Module#include?</TT>
<DT><TT>Module#included</TT>
<DT><TT>Module#method_removed</TT>
<DT><TT>Module#method_undefined</TT>
<DT><TT>Object#singleton_method_removed</TT>
<DT><TT>Object#singleton_method_undefined</TT>
<DT><TT>Proc#==</TT>
<DT><TT>Proc#yield</TT>
<DT><TT>Range#to_ary</TT>
<DT><TT>Range#step</TT>
<DT><TT>Regexp#options</TT>
<DT><TT>String#casecmp</TT>
<DT><TT>String#insert</TT>
<DT><TT>Symbol#intern</TT>
<DT><TT>Symbol::all_symbols</TT>
<DT><TT>SystemExit#status</TT>
<DT><TT>File::lchmod</TT>
<DT><TT>File::lchown</TT>
<DT><TT>IO::for_fd</TT>
<DT><TT>IO::read</TT>
<DT><TT>Math::acos</TT>
<DT><TT>Math::asin</TT>
<DT><TT>Math::atan</TT>
<DT><TT>Math::cosh</TT>
<DT><TT>Math::hypot</TT>
<DT><TT>Math::sinh</TT>
<DT><TT>Math::tanh</TT>
<DT><TT>Process::times</TT>
<DT><TT>Process::waitall</TT>
<DT><TT>SystemCallError::===</TT> </DT></DL>
<LI>
<P class=docList><TT>String#eql?</TT> is now always
case-sensitive.</P>
<LI>
<P class=docList><TT>Dir::chdir</TT> extended to take a
block.</P>
<LI>
<P class=docList><TT>NoMethodError</TT> raised for undefined
method.</P>
<LI>
<P class=docList><TT>Interrupt</TT> is a subclass of
<TT>SignalException</TT> (it was a subclass of Exception in
1.6 and prior). </P>
<LI>
<P class=docList><TT>$?</TT> now gives
<TT>Process::Status</TT> along with <TT>Process::wait2</TT>,
<TT>Process::waitpid2</TT>. </P>
<LI>
<P class=docList><TT>Regexp.last_match(n)</TT> extended to
take an optional argument. </P>
<LI>
<P class=docList><TT>The Digest</TT> module has been added
as a replacement for the <TT>md5</TT> and <TT>sha1</TT>
modules. </P>
<LI>
<P class=docList>Line-range operation is now obsolete except
when used in a one-liner (e.g., <TT>ruby</TT> <TT>-e</TT>
<TT>...</TT>). </P>
<LI>
<P class=docList>Comparison of exception classes in a rescue
clause now uses <TT>Module#===</TT>. </P>
<LI>
<P class=docList><TT>TCPSocket.new</TT> and
<TT>TCPSocket.open</TT> extended to take an address and a
port number for the local side in optional third and fourth
arguments. </P>
<LI>
<P class=docList><TT>Time</TT> extended to accept a negative
<TT>time_t</TT> (only if the platform supports it). </P>
<LI>
<P class=docList>Objects that have <TT>to_str</TT> now
behave more like strings. </P>
<LI>
<P class=docList>The <TT>Signal</TT> module has been
added.</P>
<LI>
<P class=docList>Generational garbage collection has been
added.</P></LI></UL><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?xmlid=0-59600-214-9/1061532"><IMG
height=1 src="6.2.files/pixel.htm" width=1 border=0></A>
<UL></UL></TD></TR></TBODY></TABLE>
<HR SIZE=1>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=15> </TD></TR>
<TR>
<TD class=v2 vAlign=top><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=print&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"
target=_new><IMG height=12 src="6.2.files/img_print.gif"
width=14 align=textTop border=0></A> <A class=v2
title="Printer-friendly version of this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=print&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"
target=_new>Print</A> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=email&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=9 hspace=3 src="6.2.files/img_email.gif" width=15
align=absMiddle border=0></A> <A class=v2
title="E-Mail this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=email&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1">E-Mail</A>
<A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=bookmark&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=14 hspace=3 src="6.2.files/img_bookmarks.gif" width=6
align=absMiddle border=0></A> <A class=v2
title="Add a bookmark about this section"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=bookmark&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1">Add
Bookmark</A></TD>
<TD class=v2 vAlign=top align=right> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-1&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=16 src="6.2.files/btn_prev.gif" width=56
align=absMiddle border=0></A> <A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-3&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1"><IMG
height=16 src="6.2.files/btn_next.gif" width=41
align=absMiddle border=0></A></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top align=right><A class=v1
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1#toppage">Top</A></TD></TR></TBODY></TABLE>
<P>[<A class=v2
href="http://proquest.safaribooksonline.com/0596002149/ruby-CHP-6-SECT-2">http://proquest.safaribooksonline.com/0596002149/ruby-CHP-6-SECT-2</A>]
</P></TD></TR></TBODY></TABLE></TD>
<TD align=middle> </TD></TR>
<TR>
<TD vAlign=bottom align=middle colSpan=3><BR>
<TABLE>
<TBODY>
<TR>
<TD class=v2 vAlign=center align=middle colSpan=4
height=25> <A class=v1
title="Information About Safari Tech Books Online"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=About">About
Safari</A> | <A class=v1
title="Safari Tech Books Online terms of service"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Terms">Terms
of Service</A> | <A class=v1
title="Safari Tech Books Online privacy policy"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Privacy">Privacy
Policy</A> | <A class=v1
title="Contacting Safari Tech Books Online"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Contact">Contact
Us</A> | <A class=v1
title="Safari Tech Books Online help"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Help">Help</A>
| <A class=v1
title="Submit a defect or enhancement request"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Submit">Submit
a Problem</A></TD></TR>
<TR>
<TD class=v2 vAlign=center align=middle height=20>Copyright © 2002
Safari Tech Books Online. All rights reserved.</TD></TR>
<TR vAlign=center>
<TD class=v2 vAlign=center align=middle colSpan=4 height=20>75
Arlington Street, Floor 3<BR>Boston, MA 02116<BR>800-775-7330</TD></TR>
<TR vAlign=center>
<TD class=v2 vAlign=center align=middle colSpan=4
height=5> </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><!--
(guidin)EE94E575-D563-4A31-90-AF-CA-B8-45-75-5B-41
(guidout)EE94E575-D563-4A31-90-AF-CA-B8-45-75-5B-41
(ip)147.8.179.17
(host)proquest.safaribooksonline.com
(portal)proquest
(ref)http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=toc&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1&srchText=
(base)?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-6-SECT-2&open=false&catid=&s=1&b=1&f=1&t=0&c=1&u=1
(mode)section
(xmlid)0-59600-214-9/ruby-CHP-6-SECT-2
(key)7E6FA7863F875E5D371807B896A9188D02D5BE6122A762B263800A09E833AC01645EC3A55C82E53D
(user)29536/82393
(xsl)16ms
(lib)531ms
(xml)282ms
(xsl)312ms
(ent)0ms
(buf)0ms
(tot)1422ms
--></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -