Re: [PHP-DEV] Proposal For Return-If / Early Return / Guard ClauseSyntax

This is only part of a thread. view whole thread
  110149
May 13, 2020 09:42 come.chilliet@fusiondirectory.org (=?UTF-8?B?Q8O0bWU=?= Chilliet)
Le Sun, 10 May 2020 10:49:15 -0500,
Ralph Schindler <ralph@ralphschindler.com> a écrit :
> The chosen syntax is: > > return if ( if_expr ) [: optional_return_expression] ; > > As a contrived example: > > function divide($dividend, $divisor = null) { > return if ($divisor === null || $divisor === 0); > > return $dividend / $divisor; > }
I do not understand the point, you are just reordering keywords, why is that better than already correct code: function divide($dividend, $divisor = null) { if ($divisor === null || $divisor === 0) return; return $dividend / $divisor; } I do not think an RFC and a special keyword are justified just to move the word "return" from end to beginning of line.