⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2.3.htm

📁 RUBY的参考手册~~ RUBY的参考手册~~RUBY的参考手册
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                <TD class=v2 height=18>&#8226; <A class=v2 
                  title="Search for all books by a particular author" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&amp;view=author">Author</A></TD></TR>
              <TR>
                <TD class=v2 height=18>&#8226; <A class=v2 
                  title="Search for a book by ISBN number" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&amp;view=isbn">ISBN</A></TD></TR>
              <TR>
                <TD class=v2 height=18>&#8226; <A class=v2 
                  title="Search for a book with a particular title" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&amp;view=booktitle">Title</A></TD></TR>
              <TR>
                <TD class=v2 height=18>&#8226; <A class=v2 
                  title="Search for all books by a particular publisher" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=findbook&amp;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="2.3.files/spacer.gif" width=1 border=0></TD></TR>
        <TR>
          <TD class=v1 align=middle width=188 height=1><IMG height=1 
            src="2.3.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>&nbsp;</TD></TR>
              <TR>
                <TD class=v2 vAlign=top><A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=print&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-3&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1" 
                  target=_new><IMG height=12 src="2.3.files/img_print.gif" 
                  width=14 align=textTop border=0></A> &nbsp;<A class=v2 
                  title="Printer-friendly version of this section" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=print&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-3&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1" 
                  target=_new>Print</A> &nbsp;<A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=email&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-3&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=9 hspace=3 src="2.3.files/img_email.gif" width=15 
                  align=absMiddle border=0></A> &nbsp;<A class=v2 
                  title="E-Mail this section" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=email&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-3&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1">E-Mail</A> 
                  &nbsp;<A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=bookmark&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-3&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=14 hspace=3 src="2.3.files/img_bookmarks.gif" width=6 
                  align=absMiddle border=0></A> &nbsp;<A class=v2 
                  title="Add a bookmark about this section" 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=bookmark&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-3&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1">Add 
                  Bookmark</A></TD>
                <TD class=v2 vAlign=top align=right>&nbsp; <A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-2&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=16 src="2.3.files/btn_prev.gif" width=56 
                  align=absMiddle border=0></A> &nbsp; <A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?x=1&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-4&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1"><IMG 
                  height=16 src="2.3.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="2.3.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&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1&amp;srchText=">Ruby 
                  in a Nutshell</A><BR>By Yukihiro&nbsp;Matsumoto<BR></TD></TR>
              <TR>
                <TD class=v2>&nbsp; </TD></TR>
              <TR>
                <TD class=t1 vAlign=bottom>Chapter 2.&nbsp; Language 
              Basics</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-2-SECT-3></A>
                  <H3 class=docSection1Title>2.3 Lexical Conventions</H3><A 
                  name=IXT-2-126876></A>
                  <P class=docText>Ruby programs are composed of elements 
                  already familiar to most programmers: lines, whitespace, 
                  comments, identifiers, reserved words, literals, etc. 
                  Particularly for those programmers coming from other scripting 
                  languages such as Perl, Python or tcl, you'll find Ruby's 
                  conventions familiar, or at least straightforward enough not 
                  to cause much trouble. </P><A name=ruby-CHP-2-SECT-3.1></A>
                  <H4 class=docSection2Title>2.3.1 Whitespace</H4><A 
                  name=IXT-2-126877></A>
                  <P class=docText>We'll leave the thorny questions like "How 
                  much whitespace makes code more readable and how much is 
                  distracting?" for another day. If you haven't already caught 
                  onto this theme, the Ruby interpreter will do pretty much what 
                  you expect with respect to whitespace in your code. </P>
                  <P class=docText><A name=IXT-2-126878></A><A 
                  name=IXT-2-126879></A><A name=IXT-2-126880></A><A 
                  name=IXT-2-126881></A>Whitespace characters such as spaces and 
                  tabs are generally ignored in Ruby code, except when they 
                  appear in strings. Sometimes, however, they are used to 
                  interpret ambiguous statements. Interpretations of this sort 
                  produce warnings when the <TT>-w</TT> option is enabled. </P>
                  <DL class=docList>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>a</SPAN></SPAN> <SPAN 
                    class=docPubcolor><SPAN class=docMonofont>+</SPAN></SPAN> 
                    <SPAN class=docPubcolor><SPAN 
                    class=docMonofont>b</SPAN></SPAN></SPAN> 
                    <DD>
                    <P class=docList>Interpreted as <TT>a+b</TT> (<TT>a</TT> is 
                    a local variable) </P>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>a +b</SPAN></SPAN></SPAN> 
                    <DD>
                    <P class=docList>Interpreted as <TT>a(+b)</TT> (<TT>a</TT>, 
                    in this case, is a method call) </P></DD></DL><A 
                  name=ruby-CHP-2-SECT-3.2></A>
                  <H4 class=docSection2Title>2.3.2 Line Endings</H4>
                  <P class=docText><A name=IXT-2-126882></A><A 
                  name=IXT-2-126883></A><A name=IXT-2-126884></A><A 
                  name=IXT-2-126885></A><A name=IXT-2-126886></A><A 
                  name=IXT-2-126887></A>Ruby interprets semicolons and newline 
                  characters as the ending of a statement. However, if Ruby 
                  encounters operators, such as <TT>+</TT>, <TT>-</TT>, or 
                  backslash at the end of a line, they indicate the continuation 
                  of a statement. </P><A name=ruby-CHP-2-SECT-3.3></A>
                  <H4 class=docSection2Title>2.3.3 Comments</H4><A 
                  name=IXT-2-126888></A>
                  <P class=docText><A name=IXT-2-126889></A>Comments are lines 
                  of annotation within Ruby code that are ignored at runtime. 
                  Comments extend from <TT>#</TT> to the end of the line. </P><PRE># This is a comment.</PRE>
                  <P class=docText><A name=IXT-2-126890></A><A 
                  name=IXT-2-126891></A><A name=IXT-2-126892></A><A 
                  name=IXT-2-126893></A>Ruby code can contain embedded documents 
                  too. Embedded documents extend from a line beginning with 
                  <TT>=begin</TT> to the next line beginning with <TT>=end</TT>. 
                  <TT>=begin</TT> and <TT>=end</TT> must come at the beginning 
                  of a line. </P><PRE>=begin
This is an embedded document.
=end</PRE><A name=ruby-CHP-2-SECT-3.4></A>
                  <H4 class=docSection2Title>2.3.4 Identifiers</H4><A 
                  name=IXT-2-126894></A>
                  <P class=docText><A name=IXT-2-126895></A><A 
                  name=IXT-2-126896></A><A name=IXT-2-126897></A><A 
                  name=IXT-2-126898></A><A name=IXT-2-126899></A><A 
                  name=IXT-2-126900></A><A name=IXT-2-126901></A>Identifiers are 
                  names of variables, constants, and methods. Ruby distinguishes 
                  between identifiers consisting of uppercase characters and 
                  those of lowercase characters. Identifier names may consist of 
                  alphanumeric characters and the underscore character <TT>( _ 
                  )</TT>. You can distinguish a variable's type by the initial 
                  character of its identifier. </P><A 
                  name=ruby-CHP-2-SECT-3.5></A>
                  <H4 class=docSection2Title>2.3.5 Reserved Words</H4><A 
                  name=IXT-2-126902></A>
                  <P class=docText>The following list shows the reserved words 
                  in Ruby:</P><A name=ch02-12-fm2xml></A>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -