3 puntos por smartbosslee 2020-07-16 | 3 comentarios | Compartir por WhatsApp
<p>// Antes<br /> switch ($this-&gt;lexer-&gt;lookahead['type']) {<br /> case Lexer::T_SELECT:<br /> $statement = $this-&gt;SelectStatement();<br /> break;<br /> <br /> case Lexer::T_UPDATE:<br /> $statement = $this-&gt;UpdateStatement();<br /> break;<br /> <br /> case Lexer::T_DELETE:<br /> $statement = $this-&gt;DeleteStatement();<br /> break;<br /> <br /> default:<br /> $this-&gt;syntaxError('SELECT, UPDATE o DELETE');<br /> break;<br /> }<br /> <br /> // Después<br /> $statement = match ($this-&gt;lexer-&gt;lookahead['type']) {<br /> Lexer::T_SELECT =&gt; $this-&gt;SelectStatement(),<br /> Lexer::T_UPDATE =&gt; $this-&gt;UpdateStatement(),<br /> Lexer::T_DELETE =&gt; $this-&gt;DeleteStatement(),<br /> default =&gt; $this-&gt;syntaxError('SELECT, UPDATE o DELETE'),<br /> };</p>

3 comentarios

 
kunggom 2020-07-17
<p>En Java también incluyeron en las versiones recientes una sentencia Switch con funcionalidades mejoradas. Parece que este tipo de cosas están de moda últimamente.<br /> https://es.news.hada.io/topic?id=1130</p&gt;
 
xguru 2020-07-16
<p>Nuevas funciones de PHP 8 https://es.news.hada.io/topic?id=1438<br /> <br /> Parece que cuando se publicó esta noticia todavía no estaba, pero en el artículo original de este lado también lo actualizaron y agregaron `Match`.</p>
 
smartbosslee 2020-07-16
<p>Sí. Ya está confirmado que se agregará, pero dicen que Match en sí todavía podría tener más cambios.<br /> Gracias por el enlace.</p>