Skip to content

Commit

Permalink
match expressions doesn't need always to be terminated by a semicolon
Browse files Browse the repository at this point in the history
  • Loading branch information
driade committed Jan 17, 2025
1 parent bcafb20 commit 2d66398
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions language/control-structures/match.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,38 @@ string(8) "Teenager"
The result of a <literal>match</literal> expression does not need to be used.
</simpara>
</note>
<note>
<simpara>
<para>
A <literal>match</literal> expression <emphasis>must</emphasis> be
terminated by a semicolon <literal>;</literal>.
</simpara>
</note>
</example>
terminated by a semicolon <literal>;</literal> in most scenarios.
There may be some exceptions where a semicolon is not required, such as
nested matches
<informalexample>
<programlisting role="php">
<![CDATA[
<?php
match ($a) {
match (true) {1 => 2} => match (true) {1 => 2}
};
?>
]]>
</programlisting>
</informalexample>

or operating with the result of the expression

<informalexample>
<programlisting role="php">
<![CDATA[
<?php
$output = match ($food) {
'apple' => 2,
default => 0
} + 3;
?>
]]>
</programlisting>
</informalexample>
</para>

<para>
The <literal>match</literal> expression is similar to a
Expand Down

0 comments on commit 2d66398

Please sign in to comment.