Skip to content

Conversation

thekid
Copy link
Member

@thekid thekid commented Apr 15, 2023

Inspired by https://externals.io/message/120011

class Person {
  public function __construct(private string $name) { }
  public function name(): string { return $this->name; }
}

$group= [new Person('Timm'), new Person('Alex')];

// Instead of the following:
$names= array_map(fn($person) => $person->name(), $group);

// ...we can now write this:
$names= array_map(Person->name(...), $group);

// ["Timm", "Alex"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant