You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love to see filter() be able to operate on associative arrays. There are so many cases you have a list of name-value pairs and you want to reduce this to a subset which is defined by a list of either values to exclude (black-list approach) or a list of to include only a list (white-list approach). I had hoped to have something like:
I'd be interested to know if this is better achieved a different way (as I'm still relatively new to underscore) or whether this would be seen as a worthwhile extension to the functionality if I were to fork it off.
The text was updated successfully, but these errors were encountered:
I would love to see filter() be able to operate on associative arrays. There are so many cases you have a list of name-value pairs and you want to reduce this to a subset which is defined by a list of either values to exclude (black-list approach) or a list of to include only a list (white-list approach). I had hoped to have something like:
$start = array ( "one" => "monkey" , "two" => "donkey" , "three" => "beetle" );
$filter = array ( "two", "three" );
$list = ___::filter( $start, function ($value,$key) {
return in_array( $key , $filter );
});
I'd be interested to know if this is better achieved a different way (as I'm still relatively new to underscore) or whether this would be seen as a worthwhile extension to the functionality if I were to fork it off.
The text was updated successfully, but these errors were encountered: