{"id":13490034,"url":"https://github.com/nsomar/Collection-Each","last_synced_at":"2025-03-28T05:31:43.332Z","repository":{"id":17657623,"uuid":"20462209","full_name":"nsomar/Collection-Each","owner":"nsomar","description":"Adding ruby style each iterator to Cocoa/Cocoa touch Swift Array and Range classes, And Int.times{} to Int class","archived":false,"fork":false,"pushed_at":"2014-06-07T02:34:35.000Z","size":176,"stargazers_count":65,"open_issues_count":2,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-30T00:36:24.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nsomar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-03T22:34:52.000Z","updated_at":"2024-09-08T05:06:35.000Z","dependencies_parsed_at":"2022-11-28T10:39:33.820Z","dependency_job_id":null,"html_url":"https://github.com/nsomar/Collection-Each","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsomar%2FCollection-Each","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsomar%2FCollection-Each/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsomar%2FCollection-Each/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsomar%2FCollection-Each/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nsomar","download_url":"https://codeload.github.com/nsomar/Collection-Each/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245978200,"owners_count":20703675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T19:00:39.606Z","updated_at":"2025-03-28T05:31:42.883Z","avatar_url":"https://github.com/nsomar.png","language":"Swift","readme":"Collection-Each\n===============\n\nAdding ruby style each iterator to Cocoa/Cocoa touch Swift Array, Dictionary and Range classes, and `Int.times`\n\n###Why?\n\nArray/Dictionary and Ranges in ruby have an `each` method that accepts a block as a parameter and calls this block passing the value of the item at that index.\n\nThis method is missing in swift, By extending `Array`, `Dictionary` and `Range` classes we can implement this method.\n\nBy extending `Int` we can add `times` and `timeWithIndex`\n\n###Usage\n\nArray.each\n\n\t//Iterate and pass the item\n    [\"Apples\", \"Oranges\", \"Mangos\"].each{ println(\"Item \\($0)\") }\n    \nArray.eachWithIndex\n\n\t//Iterate and pass the item and its index\n    [\"Apples\", \"Oranges\", \"Mangos\"].eachWithIndex{ println(\"Item \\($0) at Index \\($1)\") }\n\nDictionary.each\n\n\t//Iterate and pass the item\n    [\"key1\":1, \"Key2\":2, \"Key3\":3].each{ println(\"Key \\($0) at Value \\($1)\") }\n    \nInt.times\n\n\t3.times{ /* do something */ }\n\t\nInt.times\n\n\t3.timesWithIndex{ println(\"Index \\($0)\") }\n    \nRange.each\n\n\t//Iterate and pass the index\n\t(1...10).each{ println(\"Index \\($0)\") }\n\t\n###How to add?\nJust add `Collection+Each.swift` to your project and the extensions will be enabled in all your `.swift` files","funding_links":[],"categories":["Libs"],"sub_categories":["Utility"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsomar%2FCollection-Each","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsomar%2FCollection-Each","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsomar%2FCollection-Each/lists"}