Skip to content

Instantly share code, notes, and snippets.

@jackfruh
Created July 3, 2016 15:25
Show Gist options
  • Save jackfruh/bd7d50a9cc949da071850bc23a4fd429 to your computer and use it in GitHub Desktop.
Save jackfruh/bd7d50a9cc949da071850bc23a4fd429 to your computer and use it in GitHub Desktop.

#Comments

In the above code, assigning the anonymous functions to variables in the same code block works, if I assign them above.

If I assign them below, no go.

I'd like to be able to define those helper functions (ShowGreatThanZero and displayoutput) elsewhere, so that the code is neat and clean.

$showGreaterThanZero = function($value) {
return $value["ID"] > 0;
};
$displayoutput = function($value) {
$this->DisplayTheOutput($value);
};
$collection = collect($this->tables);
$filtered = $collection
->filter($showGreaterThanZero)
->pluck("Table")
->each($displayoutput);
@mlantz
Copy link

mlantz commented Jul 3, 2016

The filter is always a $value, $key I believe

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