Hi Thomas, Thomas Bley wrote:
What about using objects with list()?class Point { public function __construct($x, $y) { $this->x = $x; $this->y = $y; } } $point = new Point(21, 42); list('x' => $x, 'y' => $y) = $point;
You can't do `$x = $point['x'];`, so `list("x" => $x) = $point;` won't work either. If you want list() support, implement ArrayAccess.
We could potentially add some extension to list() for object destructuring, but I'm not sure I'd be happy with that, as list() has thus far been an array-only thing. If we ever add object literals, then we could do object destructuring with a symmetrical syntax.
Thanks. -- Andrea Faulds https://ajf.me/ -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php
