{"action":"created","issue":{"url":"https://api.github.com/repos/gosukiwi/Blueberry/issues/34","labels_url":"https://api.github.com/repos/gosukiwi/Blueberry/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/gosukiwi/Blueberry/issues/34/comments","events_url":"https://api.github.com/repos/gosukiwi/Blueberry/issues/34/events","html_url":"https://github.com/gosukiwi/Blueberry/issues/34","id":53964698,"number":34,"title":"Generator comprehensions","user":{"login":"TazeTSchnitzel","id":579774,"avatar_url":"https://avatars.githubusercontent.com/u/579774?v=3","gravatar_id":"","url":"https://api.github.com/users/TazeTSchnitzel","html_url":"https://github.com/TazeTSchnitzel","followers_url":"https://api.github.com/users/TazeTSchnitzel/followers","following_url":"https://api.github.com/users/TazeTSchnitzel/following{/other_user}","gists_url":"https://api.github.com/users/TazeTSchnitzel/gists{/gist_id}","starred_url":"https://api.github.com/users/TazeTSchnitzel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TazeTSchnitzel/subscriptions","organizations_url":"https://api.github.com/users/TazeTSchnitzel/orgs","repos_url":"https://api.github.com/users/TazeTSchnitzel/repos","events_url":"https://api.github.com/users/TazeTSchnitzel/events{/privacy}","received_events_url":"https://api.github.com/users/TazeTSchnitzel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-10T17:21:38Z","updated_at":"2015-01-10T17:34:38Z","closed_at":null,"body":"Like [list comprehensions](https://github.com/gosukiwi/Blueberry/issues/32), but produces a generator. Python has these.\r\n\r\nI know @gosukiwi stated that we don't want to require PHP 5.5+, but it wouldn't stop people with 5.4 using Blueberry, they just couldn't use generator comprehensions.\r\n\r\nIdeal syntax: \r\n\r\n* `[2 * i for i in [1..10] where i % 2 == 0]` - list comprehension\r\n\r\n* `(2 * i for i in [1..10] where i % 2 == 0)` - generator comprehension"},"comment":{"url":"https://api.github.com/repos/gosukiwi/Blueberry/issues/comments/69464029","html_url":"https://github.com/gosukiwi/Blueberry/issues/34#issuecomment-69464029","issue_url":"https://api.github.com/repos/gosukiwi/Blueberry/issues/34","id":69464029,"user":{"login":"gosukiwi","id":161972,"avatar_url":"https://avatars.githubusercontent.com/u/161972?v=3","gravatar_id":"","url":"https://api.github.com/users/gosukiwi","html_url":"https://github.com/gosukiwi","followers_url":"https://api.github.com/users/gosukiwi/followers","following_url":"https://api.github.com/users/gosukiwi/following{/other_user}","gists_url":"https://api.github.com/users/gosukiwi/gists{/gist_id}","starred_url":"https://api.github.com/users/gosukiwi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gosukiwi/subscriptions","organizations_url":"https://api.github.com/users/gosukiwi/orgs","repos_url":"https://api.github.com/users/gosukiwi/repos","events_url":"https://api.github.com/users/gosukiwi/events{/privacy}","received_events_url":"https://api.github.com/users/gosukiwi/received_events","type":"User","site_admin":false},"created_at":"2015-01-10T17:34:38Z","updated_at":"2015-01-10T17:34:38Z","body":"I love lazy collections. Generator comprehensions could easily be implemented on PHP 5.4+ using `yield`.\r\n\r\n```\r\nresult = function($collection) {\r\n    foreach($collection as $item) {\r\n         yield $item;\r\n    }\r\n}\r\n```\r\nAnother thing I really like of PHP 5.4+ is Traits, which would be an elegant way to implement Ruby-like modules. I'll leave this pull request open so anyone willing to implement Generator Comprehensions can submit a pull request :smile: "}}