<?xml version="1.0" encoding="gb2312"?>
<html lang="gb2312" xml:lang="gb2312">
<head>
<meta http-equiv="Content-type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<TITLE>Ruby参考手册 - ruby 1.7 特性</TITLE>
<link rel="stylesheet" type="text/css" href="../style.css" />
</head>
<body>
<div class="navi">
<a id="header-navi" name="head-navi"></a>
<span class="navi">[<a href="../../index.html">Ruby首页</a>]</span>
<span class="navi">[<a href="../index.html">参考手册</a>]</span>
<span class="navi">[<a href="./index.html">Ruby变更记录</a>] </span>
</div>
<DIV class=body>
<H1><A id=ruby.201.2e7.20feature name=ruby.201.2e7.20feature>ruby 1.7 特性</A><!-- RDLabel: "ruby 1.7 特性" --></H1>
<P>ruby version 1.7是开发版。将来可能会删除下列中的部分内容,也可能因为兼容性问题而对其进行修改。</P>
<H2><A id=a1.2e7.2e3.20-.3e.201.2e8.2e0.20preview1.20.282002-12-24.29
name=a1.2e7.2e3.20-.3e.201.2e8.2e0.20preview1.20.282002-12-24.29>1.7.3 ->
1.8.0 preview1 (2002-12-24)</A><!-- RDLabel: "1.7.3 -> 1.8.0 preview1 (2002-12-24)" --></H2>
<H3><A id=a2002-12-20 name=a2002-12-20>2002-12-20</A><!-- RDLabel: "2002-12-20" --></H3>
<DL>
<DT><A class=modified-old id=profiler.2erb.20.5blib.5d.20.5bnew.5d
title="profiler.rb (598d)"
name=profiler.2erb.20.5blib.5d.20.5bnew.5d>profiler.rb</A> [lib] [new]<!-- RDLabel: "profiler.rb [lib] [new]" -->
<DD>
<P>新增。作为<A class=modified-old title="profile.rb (854d)">profile.rb</A>的实体将其分离出来。</P>
<DT><A id=rb_define_alloc_func.28.29.20.5bapi.5d.20.5bnew.5d
name=rb_define_alloc_func.28.29.20.5bapi.5d.20.5bnew.5d>rb_define_alloc_func()
[api] [new]</A><!-- RDLabel: "rb_define_alloc_func() [api] [new]" -->
<DT><A id=rb_undef_alloc_func.28.29.20.5bapi.5d.20.5bnew.5d
name=rb_undef_alloc_func.28.29.20.5bapi.5d.20.5bnew.5d>rb_undef_alloc_func()
[api] [new]</A><!-- RDLabel: "rb_undef_alloc_func() [api] [new]" -->
<DD>
<P>新增。用在<A class=modified-old title="Class (661d)">allocate</A>方法的定义中。 <A
href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/19116">[ruby-dev:19116]</A></P></DD></DL>
<H3><A id=a2002-12-18 name=a2002-12-18>2002-12-18</A><!-- RDLabel: "2002-12-18" --></H3>
<DL>
<DT><A class=modified-year id=a.3d.3d.3d.20.5bcompat.5d title="Regexp (171d)"
name=a.3d.3d.3d.20.5bcompat.5d>Regexp#===</A> [compat]<!-- RDLabel: "=== [compat]" -->
<DD>
<P>返回布尔值。</P><PRE>p(/foo/ === "foo")
=> ruby 1.6.8 (2002-12-24) [i586-linux]
0
=> ruby 1.8.0 (2003-03-12) [i586-linux]
true
</PRE></DD></DL>
<H3><A id=a2002-12-17 name=a2002-12-17>2002-12-17</A><!-- RDLabel: "2002-12-17" --></H3>
<DL>
<DT><A id=defined.3f.20.5bcompat.5d name=defined.3f.20.5bcompat.5d>defined?
[compat]</A><!-- RDLabel: "defined? [compat]" -->
<DD>
<P>遇到对属性赋值或对数组元素进行赋值的情况时,返回"assignment"而非"method"。</P><PRE>class Foo
attr_accessor :foo
end
p defined? Foo.new.foo = 1
ary = []
p defined? ary[2] = 1
=> ruby 1.6.8 (2002-12-24) [i586-linux]
"method"
"method"
=> ruby 1.8.0 (2003-03-12) [i586-linux]
"assignment"
"assignment"
</PRE></DD></DL>
<H3><A id=a2002-12-17_2 name=a2002-12-17_2>2002-12-17</A><!-- RDLabel: "2002-12-17" --></H3>
<DL>
<DT><A class=modified-year id=open-uri.2erb.20.5blib.5d.20.5bnew.5d
title="open-uri.rb (325d)"
name=open-uri.2erb.20.5blib.5d.20.5bnew.5d>open-uri.rb</A> [lib] [new]<!-- RDLabel: "open-uri.rb [lib] [new]" -->
<DD>
<P>新增</P></DD></DL>
<H3><A id=a2002-12-14 name=a2002-12-14>2002-12-14</A><!-- RDLabel: "2002-12-14" --></H3>
<DL>
<DT><A id=WindowsCE.20.5bplatform.5d name=WindowsCE.20.5bplatform.5d>WindowsCE
[platform]</A><!-- RDLabel: "WindowsCE [platform]" -->
<DD>
<P>加入了<A class=modified-old title="WindowsCE (731d)">WindowsCE</A>的支持补丁。</P></DD></DL>
<H3><A id=a2002-12-11 name=a2002-12-11>2002-12-11</A><!-- RDLabel: "2002-12-11" --></H3>
<DL>
<DT><A class=modified-year id=read.20.5bcompat.5d title="IO (145d)"
name=read.20.5bcompat.5d>IO#read</A> [compat]<!-- RDLabel: "read [compat]" -->
<DT><A class=modified-year id=sysread.20.5bcompat.5d title="IO (145d)"
name=sysread.20.5bcompat.5d>IO#sysread</A> [compat]<!-- RDLabel: "sysread [compat]" -->
<DD>
<P>向IO#read, IO#sysread新增了第二参数(指定了预先分配好的读入缓冲)</P></DD></DL>
<H3><A id=a2002-12-10 name=a2002-12-10>2002-12-10</A><!-- RDLabel: "2002-12-10" --></H3>
<DL>
<DT><A class=modified-year id=terminate.20.5bnew.5d title="Thread (259d)"
name=terminate.20.5bnew.5d>Thread#terminate</A> [new]<!-- RDLabel: "terminate [new]" -->
<DD>
<P>新增。与Thread#kill 相同。</P></DD></DL>
<H3><A id=a2002-12-07 name=a2002-12-07>2002-12-07</A><!-- RDLabel: "2002-12-07" --></H3>
<DL>
<DT><A class=modified-month id=Process.2eabort.20.5bnew.5d
title="Process (7d)"
name=Process.2eabort.20.5bnew.5d>Process.abort</A> [new]<!-- RDLabel: "Process.abort [new]" -->
<DT><A class=modified-month id=Process.2eexit.20.5bnew.5d title="Process (7d)"
name=Process.2eexit.20.5bnew.5d>Process.exit</A> [new]<!-- RDLabel: "Process.exit [new]" -->
<DD>
<P>新增。与abort, exit函数相同。</P></DD></DL>
<H3><A id=a2002-12-06 name=a2002-12-06>2002-12-06</A><!-- RDLabel: "2002-12-06" --></H3>
<DL>
<DT><A class=modified-year id=pid.20.5bnew.5d title="Process::Status (311d)"
name=pid.20.5bnew.5d>Process::Status#pid</A> [new]<!-- RDLabel: "pid [new]" -->
<DD>
<P>新增</P></DD></DL>
<H3><A id=a2002-12-04 name=a2002-12-04>2002-12-04</A><!-- RDLabel: "2002-12-04" --></H3>
<DL>
<DT><A id=Object.23copy_object
name=Object.23copy_object>Object#copy_object</A><!-- RDLabel: "Object#copy_object" -->
<DD>
<P>改名了,原名为become。(此后,在1.8中又改名为initialize_copy)</P></DD></DL>
<H3><A id=a2002-11-27 name=a2002-11-27>2002-11-27</A><!-- RDLabel: "2002-11-27" --></H3>
<DL>
<DT><A class=modified-year id=SystemExit.2enew.20.5bcompat.5d
title="SystemExit (172d)"
name=SystemExit.2enew.20.5bcompat.5d>SystemExit#initialize</A> [compat]<!-- RDLabel: "SystemExit.new [compat]" -->
<DD>
<P>增加了参数。</P><PRE>ruby -e 'raise SystemExit.new(2)'
echo $?
# => 2
</PRE></DD></DL>
<H3><A id=a2002-11-19 name=a2002-11-19>2002-11-19</A><!-- RDLabel: "2002-11-19" --></H3>
<DL>
<DT><A class=modified-month id=transpose.20.5bnew.5d title="Array (11d)"
name=transpose.20.5bnew.5d>Array#transpose</A> [new]<!-- RDLabel: "transpose [new]" -->
<DD>
<P>新增</P><PRE>p [[1,2,3],
[4,5,6],
[7,8,9]].transpose
=> ruby 1.7.3 (2002-12-11) [i586-linux]
[[1, 4, 7], [2, 5, 8], [3, 6, 9]]
</PRE></DD></DL>
<H3><A id=a2002-11-08 name=a2002-11-08>2002-11-08</A><!-- RDLabel: "2002-11-08" --></H3>
<DL>
<DT><A id=a.5bparser.5d.20.5bexperimental.5d
name=a.5bparser.5d.20.5bexperimental.5d>[parser] [experimental]</A><!-- RDLabel: "[parser] [experimental]" -->
<DD>
<P>试验性的修改。</P><PRE>a = 1
p a / 5
=> ruby 1.6.8 (2002-12-24) [i586-linux]
0
=> ruby 1.8.0 (2003-03-12) [i586-linux]
0
a = 1
p a /5
=> -:2: warning: ambiguous first argument; make sure
-:2: unterminated regexp meets end of file
ruby 1.6.8 (2002-12-24) [i586-linux]
=> ruby 1.8.0 (2003-03-12) [i586-linux]
0
</PRE></DD></DL>
<H3><A id=a2002-11-02 name=a2002-11-02>2002-11-02</A><!-- RDLabel: "2002-11-02" --></H3>
<DL>
<DT><A class=modified-year id=object_id.20.5bnew.5d title="Object (171d)"
name=object_id.20.5bnew.5d>Object#object_id</A> [new]<!-- RDLabel: "object_id [new]" -->
<DD>
<P>新增 (Object#id是obsolete)</P><PRE>p Object.new.id
=> ruby 1.6.7 (2002-03-01) [i586-linux]
537730140
=> -:1: warning: Object#id will be deprecated; use Object#object_id
ruby 1.7.3 (2002-12-04) [i586-linux]
537723790
</PRE></DD></DL>
<H3><A id=a2002-11-02_2 name=a2002-11-02_2>2002-11-02</A><!-- RDLabel: "2002-11-02" --></H3>
<DL>
<DT><A class=modified-old id=to_sym.20.5bnew.5d title="Fixnum (687d)"
name=to_sym.20.5bnew.5d>Fixnum#to_sym</A> [new]<!-- RDLabe
ruby教程.rar
4星 · 超过85%的资源 需积分: 0 86 浏览量
更新于2008-08-29
2
收藏 191KB RAR 举报
目录
更新记录
卷首语
Ruby的启动
命令行选项
关于解释器行
环境变量
Ruby 语言样式
对象
类
执行
结束时的相关处理
线程
安全模型
正则表达式
Ruby的语法
字句构造
程序
变量和常数
字面值
操作符表达式
控制结构/异常处理
方法调用
类/方法的定义
标准库
内部函数
内部变量
内部常数
内部类/模块/异常类
附加库
Ruby变更记录
ruby 1.6 特性
ruby 1.7 特性
ruby 1.8 特性
1.6.8到1.8.0的变更点(总结)
ruby 1.9 特性
obsolete
对应DOSISH
附录
疑似BNF的Ruby语法
Ruby术语集
Ruby的运行平台
pack模板字符串
sprintf格式
Marshal格式
Ruby FAQ
Ruby的陷阱
Ruby/Tk FAQ
Ruby的相关书籍
Ruby Documentation Project (RDP)
HTML Help版和分立HTML
ReFe
索引
功能分类索引
发布条件
- 1
- 2
前往页