Closed
Conversation
Contributor
|
Nice methods. I think we should revisit the idea of wrapping the scalars/arrays in objects. |
Contributor
Author
That makes very little sense if not supported by language. Wait for PHP 7. |
5617d88 to
209844d
Compare
5ed86bc to
509ef5e
Compare
6c03b1f to
a4bddc8
Compare
2998062 to
f6303c6
Compare
Member
|
Now it (i.e. class Iterators
{
public static function map($iterator, callable $callback)
{
foreach ($iterator as $key => $value) {
yield $key => $callback($value);
}
}
public static function filter($iterator, callable $callback)
{
foreach ($iterator as $key => $value) {
if ($callback($value)) {
yield $key => $value;
}
}
} |
Contributor
Author
|
Yes. But I would expect |
Contributor
|
@dg Generators are good but I don't think we need functions like this in Nette. Just use nikic/iter. |
46f5434 to
ecbbdfc
Compare
ae4dce9 to
3d2aa29
Compare
c8398ca to
47dc563
Compare
dg
added a commit
that referenced
this pull request
Dec 19, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I love those methody in JS, would be nice to have them in PHP as well. What do you think?