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

📄 2.6.htm

📁 RUBY的参考手册~~ RUBY的参考手册~~RUBY的参考手册
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                    <DT><SPAN class=docPubcolor><TT><I>expr1</I></TT> <SPAN 
                    class=docPubcolor><SPAN class=docMonofont>..</SPAN></SPAN> 
                    <TT><I>expr2</I></TT></SPAN> 
                    <DD>
                    <P class=docList>Includes both expressions 
                    (<TT><I>expr1</I></TT> <TT>&lt;=</TT> <TT>x</TT> 
                    <TT>&lt;=</TT> <TT><I>expr2</I></TT>) </P>
                    <DT><SPAN class=docPubcolor><TT><I>expr1</I></TT> <SPAN 
                    class=docPubcolor><SPAN class=docMonofont>...</SPAN></SPAN> 
                    <TT><I>expr2</I></TT></SPAN> 
                    <DD>
                    <P class=docList>Doesn't include the last expression 
                    (<TT><I>expr1</I></TT> <TT>&lt;=</TT> <TT>x</TT> 
                    <TT>&lt;</TT> <TT><I>expr2</I></TT>) </P></DD></DL><A 
                  name=ruby-CHP-2-SECT-6.1.3></A>
                  <H5 class=docSection3Title>2.6.1.3 Logical operators</H5><A 
                  name=IXT-2-127000></A>
                  <P class=docText>If the value of the entire expression can be 
                  determined with the value of the left operand alone, the right 
                  operand isn't evaluated. </P><A name=IXT-2-127001></A>
                  <DL class=docList><A name=IXT-2-127001></A>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>&amp;&amp; and</SPAN></SPAN></SPAN> 
                    <DD>
                    <P class=docList>Returns <TT>true</TT> if both operands are 
                    <TT>true</TT>. If the left operand is <TT>false</TT>, 
                    returns the value of the left operand, otherwise returns the 
                    value of the right operand. </P>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>|| or</SPAN></SPAN></SPAN> 
                    <DD>
                    <P class=docList>Returns <TT>true</TT> if either operand is 
                    <TT>true</TT>. If the left operand is <TT>true</TT>, returns 
                    the value of the left operand, otherwise returns the value 
                    of the right operand. </P>
                    <P class=docList>The operators <TT>and</TT> and <TT>or</TT> 
                    have extremely low precedence. </P></DD></DL><A 
                  name=ruby-CHP-2-SECT-6.1.4></A>
                  <H5 class=docSection3Title>2.6.1.4 Ternary operator</H5><A 
                  name=IXT-2-127002></A>
                  <P class=docText>Ternary <TT>?:</TT> is the conditional 
                  operator. It's another form of the <TT>if</TT> statement. 
                  </P><A name=IXT-2-127003></A>
                  <DL class=docList>
                    <DT><SPAN class=docPubcolor><TT><I>a</I></TT> <SPAN 
                    class=docPubcolor><SPAN class=docMonofont>?</SPAN></SPAN> 
                    <TT><I>b</I></TT> <SPAN class=docPubcolor><SPAN 
                    class=docMonofont>:</SPAN></SPAN> <TT><I>c</I></TT></SPAN> 
                    <DD>
                    <P class=docList><A name=IXT-2-127003></A>If 
                    <TT><I>a</I></TT> is <TT>true</TT>, evaluates 
                    <TT><I>b</I></TT>, otherwise evaluates <TT><I>c</I></TT>. 
                    It's best to insert spaces before and after the operators to 
                    avoid mistaking the first part for the method 
                    <TT><I>a</I></TT><TT>?</TT> and the second part for the 
                    symbol <TT>:</TT><TT><I>c</I></TT>. </P></DD></DL><A 
                  name=ruby-CHP-2-SECT-6.1.5></A>
                  <H5 class=docSection3Title>2.6.1.5 defined? operator</H5><A 
                  name=IXT-2-127004></A>
                  <P class=docText><TT>defined?</TT> is a special operator that 
                  takes the form of a method call to determine whether or not 
                  the passed expression is defined. It returns a description 
                  string of the expression, or <TT>nil</TT> if the expression 
                  isn't defined. </P><A name=IXT-2-127005></A><A 
                  name=IXTR3-4></A>
                  <DL class=docList>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>defined?</SPAN></SPAN> 
                    <TT><I>variable</I></TT></SPAN> 
                    <DD>
                    <P class=docList>True if <TT><I>variable</I></TT> is 
                    initialized</P><PRE>foo = 42
defined? foo      # =&gt; "local-variable"
defined? $_       # =&gt; "global-variable"
defined? bar      # =&gt; nil (undefined)</PRE>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>defined?</SPAN></SPAN> 
                    <TT><I>method_call</I></TT></SPAN> 
                    <DD>
                    <P class=docList><A name=IXT-2-127005></A>True if a method 
                    is defined (also checks arguments) </P><PRE>defined? puts      # =&gt; "method"
defined? puts(bar) # =&gt; nil (bar is not defined here)
defined? unpack    # =&gt; nil (not defined here)</PRE>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>defined? super</SPAN></SPAN></SPAN> 
                    <DD>
                    <P class=docList>True if a method exists that can be called 
                    with <TT>super</TT> </P><PRE>defined? super     # =&gt; "super" (if it can be called)
defined? super     # =&gt; nil     (if it cannot be)</PRE>
                    <DT><SPAN class=docPubcolor><SPAN class=docPubcolor><SPAN 
                    class=docMonofont>defined? yield</SPAN></SPAN></SPAN> 
                    <DD>
                    <P class=docList>True if a code block has been passed</P><A 
                    name=IXTR3-4></A><PRE>defined? yield   # =&gt; "yield" (if there is a block passed)
defined? yield   # =&gt; nil     (if there is no block)</PRE></DD></DL><A 
                  href="http://proquest.safaribooksonline.com/JVXSL.asp?xmlid=0-59600-214-9/1061532"><IMG 
                  height=1 src="2.6.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>&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-6&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.6.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-6&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-6&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.6.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-6&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-6&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.6.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-6&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-5&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.6.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-7&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.6.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&amp;mode=section&amp;sortKey=title&amp;sortOrder=asc&amp;view=&amp;xmlid=0-59600-214-9/ruby-CHP-2-SECT-6&amp;open=false&amp;catid=&amp;s=1&amp;b=1&amp;f=1&amp;t=1&amp;c=1&amp;u=1#toppage">Top</A></TD></TR></TBODY></TABLE>
            <P>[<A class=v2 
            href="http://proquest.safaribooksonline.com/0596002149/ruby-CHP-2-SECT-6">http://proquest.safaribooksonline.com/0596002149/ruby-CHP-2-SECT-6</A>] 
            </P></TD></TR></TBODY></TABLE></TD>
    <TD align=middle>&nbsp;</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>&nbsp;&nbsp; <A class=v1 
            title="Information About Safari Tech Books Online" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=About">About 
            Safari</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Safari Tech Books Online terms of service" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Terms">Terms 
            of Service</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Safari Tech Books Online privacy policy" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Privacy">Privacy 
            Policy</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Contacting Safari Tech Books Online" 
            href="http://proquest.safaribooksonline.com/JVXSL.asp?mode=Contact">Contact 
            Us</A> &nbsp;&nbsp;|&nbsp;&nbsp; <A class=v1 
            title="Safari Tec

⌨️ 快捷键说明

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