Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

if (is Bar foo) should narrow to Foo&Bar

  • Loading branch information...
commit 1d42dfe1f91492d566735515d532347a1572fd9b 1 parent 9e27d74
@gavinking gavinking authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 en/modules/statementblocks.xml
View
13 en/modules/statementblocks.xml
@@ -1573,21 +1573,22 @@ else {
</listitem>
<listitem>
<para>if the condition contains a value reference, the value will be treated by the
- compiler as having the specified type inside the block that immediately follows the
- condition.</para>
+ compiler as having the intersection type of the specified type with the type of the
+ value inside the block that immediately follows the condition.</para>
</listitem>
</itemizedlist>
<para>If you prefer, you can think of the following:</para>
- <programlisting>if (is Usable obj) { ... }</programlisting>
+ <programlisting>Transaction tx = ...
+if (is Usable tx) { ... }</programlisting>
<para>As an abbreviation of:</para>
- <programlisting>if (is Usable obj = obj) { ... }</programlisting>
+ <programlisting>if (is Transaction&amp;Usable tx = tx) { ... }</programlisting>
- <para>Where the <literal>obj</literal> declared by the condition hides the outer declaration
- of <literal>obj</literal> inside the block that follows.</para>
+ <para>Where the <literal>tx</literal> declared by the condition hides the outer declaration
+ of <literal>tx</literal> inside the block that follows.</para>
<para>The condition is satisfied if the value reference or expression evaluates to an
instance of the required type when the control structure containing the condition is
Please sign in to comment.
Something went wrong with that request. Please try again.