Closed thekid closed 3 years ago
If we allowed unpacking of placeholders via ...?
, we could further simplify the sequence example:
class Person {
public function __construct(public int $id, public string $name) { }
}
// Creates instances from database records and writes them to the console
Sequence::of($conn->query('select * from person'))
->map(new Person(...?))
->each(Console::writeLine('> ', ?))
;
When we pass around objects as parameters, the placeholder would have to be able to replace the object in something like the following:
$filtered= Sequence::of(...)->filter(fn($user) => $user->isActive());
$filtered= Sequence::of(...)->filter(?->isActive());
Hrm...
RFC was declined, closing
RFC was declined, closing
it would have been still a nice feature
Examples
This code:
...can be rewritten to:
See also
Depends on xp-framework/ast#26