📄 1.1.htm
字号:
<TD class=v2 vAlign=top align=left width="100%" colSpan=14
height=18><A class=v2 title=Multimedia
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=books&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=multi&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Multimedia</A></TD></TR>
<TR vAlign=top>
<TD class=v2> </TD>
<TD class=v2 vAlign=center align=left width=14 height=18><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=network&s=1&b=1&f=1&t=1&c=1&u=1&srchText="><IMG
height=9 src="1.1.files/sign_plus.gif" width=14 vspace=2
border=0></A></TD>
<TD class=v2 vAlign=top align=left width="100%" colSpan=14
height=18><A class=v2 title=Networking
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=books&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=network&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Networking</A></TD></TR>
<TR vAlign=top>
<TD class=v2> </TD>
<TD class=v2 vAlign=center align=left width=14 height=18><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=opsys&s=1&b=1&f=1&t=1&c=1&u=1&srchText="><IMG
height=9 src="1.1.files/sign_plus.gif" width=14 vspace=2
border=0></A></TD>
<TD class=v2 vAlign=top align=left width="100%" colSpan=14
height=18><A class=v2 title="Operating Systems"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=books&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=opsys&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Operating
Systems</A></TD></TR>
<TR vAlign=top>
<TD class=v2> </TD>
<TD class=v2 vAlign=center align=left width=14 height=18><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=prog&s=1&b=1&f=1&t=1&c=1&u=1&srchText="><IMG
height=9 src="1.1.files/sign_plus.gif" width=14 vspace=2
border=0></A></TD>
<TD class=v2 vAlign=top align=left width="100%" colSpan=14
height=18><A class=v2 title=Programming
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=books&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=prog&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Programming</A></TD></TR>
<TR vAlign=top>
<TD class=v2> </TD>
<TD class=v2 vAlign=center align=left width=14 height=18><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=sweng&s=1&b=1&f=1&t=1&c=1&u=1&srchText="><IMG
height=9 src="1.1.files/sign_plus.gif" width=14 vspace=2
border=0></A></TD>
<TD class=v2 vAlign=top align=left width="100%" colSpan=14
height=18><A class=v2 title="Software Engineering"
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=books&sortKey=title&sortOrder=asc&view=&xmlid=&open=true&catid=sweng&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Software
Engineering</A></TD></TR>
<TR>
<TD class=v1 colSpan=16 height=10></TD></TR></TBODY></TABLE><A
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9/ruby-CHP-1-SECT-1&open=false&catid=&s=1&b=1&f=0&t=1&c=1&u=1"><IMG
src="1.1.files/left_findbook.gif" border=0></A><BR>
<TABLE id=Out3details cellSpacing=0 cellPadding=0 width="95%"
border=0>
<TBODY>
<TR>
<TD class=v1 height=8></TD></TR>
<TR>
<TD class=v2 height=18>• <A class=v2
title="Search for all books by a particular author"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&view=author">Author</A></TD></TR>
<TR>
<TD class=v2 height=18>• <A class=v2
title="Search for a book by ISBN number"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&view=isbn">ISBN</A></TD></TR>
<TR>
<TD class=v2 height=18>• <A class=v2
title="Search for a book with a particular title"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&view=booktitle">Title</A></TD></TR>
<TR>
<TD class=v2 height=18>• <A class=v2
title="Search for all books by a particular publisher"
href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&view=publ">Publisher</A></TD></TR>
<TR>
<TD class=v1 height=5></TD></TR></TBODY></TABLE></TD>
<TD align=right width=1 rowSpan=3><IMG height=1
src="1.1.files/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD class=v1 align=middle width=188 height=1><IMG height=1
src="1.1.files/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE></DIV></FORM></TD>
<TD align=middle>
<TABLE width="95%">
<TBODY>
<TR>
<TD class=v2 align=middle>
<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-1-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"
target=_new><IMG height=12 src="1.1.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-1-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&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-1-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=9 hspace=3 src="1.1.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-1-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&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-1-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=14 hspace=3 src="1.1.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-1-SECT-1&open=false&catid=&s=1&b=1&f=1&t=1&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-1&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=16 src="1.1.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-1-SECT-2&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1"><IMG
height=16 src="1.1.files/btn_next.gif" width=41
align=absMiddle border=0></A></TD></TR></TBODY></TABLE>
<HR SIZE=1>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top width=67 rowSpan=3><IMG
src="1.1.files/ruby_xs.gif" width=67 border=0></TD>
<TD class=v2 vAlign=top><A class=v1
href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&mode=section&sortKey=title&sortOrder=asc&view=&xmlid=0-59600-214-9&open=false&catid=&s=1&b=1&f=1&t=1&c=1&u=1&srchText=">Ruby
in a Nutshell</A><BR>By Yukihiro Matsumoto<BR></TD></TR>
<TR>
<TD class=v2> </TD></TR>
<TR>
<TD class=t1 vAlign=bottom>Chapter 1.
Introduction</TD></TR></TBODY></TABLE>
<HR SIZE=1>
<BR>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD vAlign=top><A name=ruby-CHP-1-SECT-1></A>
<H3 class=docSection1Title>1.1 Ruby's Elegance</H3>
<P class=docText><A name=IXT-1-126773></A><A
name=IXT-1-126774></A>Ruby is a genuine object-oriented
scripting language designed from the ground up to support the
OOP model. </P>
<P class=docText>Most modern languages incorporate aspects of
object-oriented programming. Because Ruby was designed from
the beginning to support OOP, most programmers feel it is
elegant, easy to use, and a pleasure to program. Everything in
Ruby is an object; there's no exception. </P>
<P class=docText>While Ruby is object-oriented, you can also
use Ruby to do procedural programming. But as you do, Ruby is
secretly turning your nifty procedures into methods on a
globally accessible object. </P>
<P class=docText>Throughout the development of the Ruby
language, I've focused my energies on making programming
faster and easier. To do so, I developed what I call the <SPAN
class=docEmphasis>principle of least surprise</SPAN>. All
features in Ruby, including object-oriented features, are
designed to work as ordinary programmers (e.g., me) expect
them to work. Here are some of those features: </P><A
name=IXT-1-126775></A><A name=IXT-1-126776></A><A
name=IXT-1-126777></A><A name=IXT-1-126778></A><A
name=IXT-1-126779></A><A name=IXT-1-126780></A><A
name=IXT-1-126781></A><A name=IXT-1-126782></A>
<DL class=docList>
<DT><SPAN class=docPubcolor><SPAN
class=docEmphasis>Interpretive programming</SPAN><A
name=IXT-1-126775></A></SPAN>
<DD>
<P class=docList>No compilation is needed; you can edit and
feed your program to the interpreter. The faster development
cycle helps you enjoy the programming process. </P>
<DT><SPAN class=docPubcolor><SPAN class=docEmphasis>Dynamic
programming</SPAN><A name=IXT-1-126776></A></SPAN>
<DD>
<P class=docList>Almost everything in Ruby is done at
runtime. Types of variables and expressions are determined
at runtime as are class and method definitions. You can even
generate programs within programs and execute them. </P>
<DT><SPAN class=docPubcolor><SPAN class=docEmphasis>Familiar
syntax</SPAN><A name=IXT-1-126777></A><A
name=IXT-1-126778></A><A name=IXT-1-126779></A></SPAN>
<DD>
<P class=docList>If you've been programming in Java, Perl,
Python, C/C++, or even Smalltalk, Ruby's syntax is easy to
learn. The following simple factorial function illustrates
how easily you can decipher its meaning: </P><PRE>def factorial(n)
if n == 0
return 1
else
return n * factorial(n-1)
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -