old-code/monodoc/ecma334/14.9.xml

15 строки
3.1 KiB
XML

<?xml version="1.0"?>
<clause number="14.9" title="Relational and type-testing operators">
<paragraph>The ==, !=, &lt;, &gt;, &lt;=, &gt;=, is and as operators are called the relational and type-testing operators. <grammar_production><name><non_terminal where="14.9">relational-expression</non_terminal></name> : <rhs><non_terminal where="14.8">shift-expression</non_terminal></rhs><rhs><non_terminal where="14.9">relational-expression</non_terminal><terminal>&lt;</terminal><non_terminal where="14.8">shift-expression</non_terminal></rhs><rhs><non_terminal where="14.9">relational-expression</non_terminal><terminal>&gt;</terminal><non_terminal where="14.8">shift-expression</non_terminal></rhs><rhs><non_terminal where="14.9">relational-expression</non_terminal><terminal>&lt;=</terminal><non_terminal where="14.8">shift-expression</non_terminal></rhs><rhs><non_terminal where="14.9">relational-expression</non_terminal><terminal>&gt;=</terminal><non_terminal where="14.8">shift-expression</non_terminal></rhs><rhs><non_terminal where="14.9">relational-expression</non_terminal><keyword>is</keyword><non_terminal where="11">type</non_terminal></rhs><rhs><non_terminal where="14.9">relational-expression</non_terminal><keyword>as</keyword><non_terminal where="11">type</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="14.9">equality-expression</non_terminal></name> : <rhs><non_terminal where="14.9">relational-expression</non_terminal></rhs><rhs><non_terminal where="14.9">equality-expression</non_terminal><terminal>==</terminal><non_terminal where="14.9">relational-expression</non_terminal></rhs><rhs><non_terminal where="14.9">equality-expression</non_terminal><terminal>!=</terminal><non_terminal where="14.9">relational-expression</non_terminal></rhs></grammar_production></paragraph>
<paragraph>The is operator is described in <hyperlink>14.9.9</hyperlink> and the as operator is described in <hyperlink>14.9.10</hyperlink>. </paragraph>
<paragraph>The ==, !=, &lt;, &gt;, &lt;= and &gt;= operators are comparison operators. For an operation of the form x op y, where op is a comparison operator, overload resolution (<hyperlink>14.2.4</hyperlink>) is applied to select a specific operator implementation. The operands are converted to the parameter types of the selected operator, and the type of the result is the return type of the operator. </paragraph>
<paragraph>The predefined comparison operators are described in the following sections. All predefined comparison operators return a result of type <keyword>bool</keyword>, as described in the following table. <table_line>Operation Result </table_line>
<table_line>x == y true if x is equal to y, false otherwise </table_line>
<table_line>x != y true if x is not equal to y, false otherwise </table_line>
<table_line>x &lt; y true if x is less than y, false otherwise </table_line>
<table_line>x &gt; y true if x is greater than y, false otherwise </table_line>
<table_line>x &lt;= y true if x is less than or equal to y, false otherwise </table_line>
<table_line>x &gt;= y true if x is greater than or equal to y, false otherwise </table_line>
</paragraph>
</clause>