Re: [RFC][DISCUSSION] Allow default value in list() syntax

From: Date: Thu, 10 Aug 2017 22:40:08 +0000
Subject: Re: [RFC][DISCUSSION] Allow default value in list() syntax
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-100176@lists.php.net to get a copy of this message
On Fri, Aug 11, 2017 at 12:01 AM, Devnuhl Unnamed <devnuhl@gmail.com> wrote: > Would isset($suffix) not suffice here? You mean like so? list($prefix, $suffix) = explode(':', 'string_without_suffix'); if (!isset($suffix)) { .. } The isset() is too late here, because the list() will already cause an error. > Other concerns fall around list() already being a difficult thing for people to understand I fail to understand what is difficult about it.. And "destructuring" is a common concept in programming languages. https://www.startpage.com/do/search?query=destructuring&cat=web&pl=chrome&language=english https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment The following already works in Javascript: [a, b, c, d = 'else'] = ['aa', 'bb', 'cc']; I just tried it in my Chromium console.

« previous php.internals (#100176) next »