{"action":"created","issue":{"url":"https://api.github.com/repos/manastech/crystal/issues/1193","labels_url":"https://api.github.com/repos/manastech/crystal/issues/1193/labels{/name}","comments_url":"https://api.github.com/repos/manastech/crystal/issues/1193/comments","events_url":"https://api.github.com/repos/manastech/crystal/issues/1193/events","html_url":"https://github.com/manastech/crystal/issues/1193","id":101248139,"number":1193,"title":"Array#product","user":{"login":"And3s","id":6330455,"avatar_url":"https://avatars.githubusercontent.com/u/6330455?v=3","gravatar_id":"","url":"https://api.github.com/users/And3s","html_url":"https://github.com/And3s","followers_url":"https://api.github.com/users/And3s/followers","following_url":"https://api.github.com/users/And3s/following{/other_user}","gists_url":"https://api.github.com/users/And3s/gists{/gist_id}","starred_url":"https://api.github.com/users/And3s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/And3s/subscriptions","organizations_url":"https://api.github.com/users/And3s/orgs","repos_url":"https://api.github.com/users/And3s/repos","events_url":"https://api.github.com/users/And3s/events{/privacy}","received_events_url":"https://api.github.com/users/And3s/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-16T09:52:39Z","updated_at":"2015-08-16T13:08:21Z","closed_at":"2015-08-16T13:08:21Z","body":"```\r\n[1, 2].product([3, 4]) do |x|\r\n    p x\r\nend\r\n\r\n# ruby\r\n# [1, 3]\r\n# [1, 4]\r\n# [2, 3]\r\n# [2, 4]\r\n\r\n# crystal\r\n# 1\r\n# 1\r\n# 2\r\n# 2\r\n\r\n[1, 2].product([3, 4], [5, 6]) do |x|\r\n    p x\r\nend\r\n\r\n# ruby\r\n\r\n# [1, 3, 5]\r\n# [1, 3, 6]\r\n# [1, 4, 5]\r\n# [1, 4, 6]\r\n# [2, 3, 5]\r\n# [2, 3, 6]\r\n# [2, 4, 5]\r\n# [2, 4, 6]\r\n\r\n\r\n# crystal\r\n# wrong number of arguments for 'Array(Int32)#product' (2 for 1)\r\n```"},"comment":{"url":"https://api.github.com/repos/manastech/crystal/issues/comments/131547199","html_url":"https://github.com/manastech/crystal/issues/1193#issuecomment-131547199","issue_url":"https://api.github.com/repos/manastech/crystal/issues/1193","id":131547199,"user":{"login":"asterite","id":209371,"avatar_url":"https://avatars.githubusercontent.com/u/209371?v=3","gravatar_id":"","url":"https://api.github.com/users/asterite","html_url":"https://github.com/asterite","followers_url":"https://api.github.com/users/asterite/followers","following_url":"https://api.github.com/users/asterite/following{/other_user}","gists_url":"https://api.github.com/users/asterite/gists{/gist_id}","starred_url":"https://api.github.com/users/asterite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asterite/subscriptions","organizations_url":"https://api.github.com/users/asterite/orgs","repos_url":"https://api.github.com/users/asterite/repos","events_url":"https://api.github.com/users/asterite/events{/privacy}","received_events_url":"https://api.github.com/users/asterite/received_events","type":"User","site_admin":false},"created_at":"2015-08-16T13:08:21Z","updated_at":"2015-08-16T13:08:21Z","body":"In Crystal Array#product yields two elements, [like this](http://play.crystal-lang.org/#/r/bi8).\r\n\r\nFor the multi-array variant you can use `Array.each_product`, just added by kostya (so it's in HEAD):\r\n\r\n```crystal\r\nArray.each_product([[1, 2], [3, 4], [5, 6]]) do |x|\r\n  p x\r\nend\r\n```\r\n\r\nI wouldn't like `Array#product` with a block to create intermediary arrays, as you almost always want the individual elements, and doing the product of two arrays is the most common case.\r\n\r\nAlso see [this comment](https://github.com/manastech/crystal/issues/105#issuecomment-131547103).\r\n\r\n"}}