// This...
$actions= [new Add()];
if ($admin) $actions[]= new Delete();
$actions[]= new Delete();
// ...or this:
$actions= array_filter([new Add(), $admin ? new Delete() : null, new Edit()];
// ...becomes:
$actions= [new Add(), if ($admin) yield new Delete(), new Edit()];
Examples
for
if
foreach
See https://docs.python.org/3/reference/expressions.html and https://dart.dev/guides/language/language-tour#collection-operators
/cc @mikey179