{"id":1027,"url":"https://github.com/ankurp/Dollar","last_synced_at":"2025-08-06T16:32:17.611Z","repository":{"id":17661420,"uuid":"20466037","full_name":"ankurp/Dollar","owner":"ankurp","description":"A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript","archived":false,"fork":false,"pushed_at":"2024-02-29T03:59:14.000Z","size":5587,"stargazers_count":4253,"open_issues_count":3,"forks_count":368,"subscribers_count":103,"default_branch":"master","last_synced_at":"2024-10-29T15:08:07.207Z","etag":null,"topics":["callback-returns","dollar","swift","swift-language","xcode"],"latest_commit_sha":null,"homepage":"https://www.dollarswift.org","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ankurp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-04T01:30:39.000Z","updated_at":"2024-10-22T13:14:12.000Z","dependencies_parsed_at":"2024-04-27T23:32:46.400Z","dependency_job_id":"3d694eff-39c2-4632-9004-8f6e05bd893d","html_url":"https://github.com/ankurp/Dollar","commit_stats":{"total_commits":471,"total_committers":54,"mean_commits":8.722222222222221,"dds":"0.28025477707006374","last_synced_commit":"b8f59e286fcc30c53e270ab55e78c1b0e4706e9c"},"previous_names":["ankurp/dollar.swift"],"tags_count":45,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankurp%2FDollar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankurp%2FDollar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankurp%2FDollar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ankurp%2FDollar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ankurp","download_url":"https://codeload.github.com/ankurp/Dollar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923757,"owners_count":17992574,"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":["callback-returns","dollar","swift","swift-language","xcode"],"created_at":"2024-01-05T20:15:37.354Z","updated_at":"2024-12-09T16:31:19.569Z","avatar_url":"https://github.com/ankurp.png","language":"Swift","readme":"Dollar ![CocoaPods](https://img.shields.io/cocoapods/v/Dollar.svg) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)\n===========\n\nDollar is a Swift library that provides useful functional programming helper methods without extending any built in objects. It is similar to [Lo-Dash](https://lodash.com) or [Underscore.js](http://underscorejs.org) in Javascript.\n\n[Cent](https://github.com/ankurp/Cent) is a library that extends certain Swift object types using the extension feature and gives its two cents to Swift language. It is now moved into a separate repo to support `Swift Package Manager`\n\nNOTE: Starting Swift 4 `$` is no longer a valid identifier. So you get the following `error: '$' is not an identifier; use backticks to escape it` . Instead use `Dollar`.\n\n## Contents ##\n\n- [Setup](#setup)\n  - [Demo App](#demo-app)\n- [API Documentation](http://www.dollarswift.org)\n- [Usage](#dollar-usage)\n  - [Array](#array)\n  - [Dictionary](#dictionary)\n  - [Object](#object)\n  - [Function](#function)\n  - [Chaining](#chaining)\n- [Contributing](#contributing)\n\n# Setup #\n\n## Using [cocoapods](http://cocoapods.org/) version 0.36.x or greater\n\nAdd `pod 'Dollar'` to your `Podfile` and run `pod install`. Add `use_frameworks!` to the end of the `Podfile`. Also checkout this [sample app](https://github.com/ankurp/DollarPodApp).\n\n## Using [Swift Package Manager](https://github.com/apple/swift-package-manager)\n\nAdd the following dependency `.Package(url: \"https://github.com/ankurp/Dollar\", majorVersion: 7, minor: 1)` to your `Package.swift` file and then run `swift build`. Requires swift version 2.2 or greater that you can install from https://swift.org\n\n## Using `git submodule`\n\n1. If you are using git then add Dollar as a submodule using `git submodule add https://github.com/ankurp/Dollar.git`. If not using git download the project using `git clone https://github.com/ankurp/Dollar.git` in your project folder.\n2. Open the `Dollar` folder. Drag Dollar.xcodeproj, inside the Dollar folder, into the file navigator of your Xcode project.\n3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the \"Targets\" heading in the sidebar.\n4. In the tab bar at the top of that window, open the \"Build Phases\" panel.\n5. Expand the \"Link Binary with Libraries\" group, and add Dollar.framework.\n6. In your project file `import Dollar` and you can call all of the helper functions.\n\nStill stuck. Then checkout this screencast on [how to import](http://recordit.co/0gQiCSEREF)\n\n## Support for Xcode and Swift\n\n* For Xcode 15 (Swift 5.1) use version `10.0.0`\n* For Xcode 11 (Swift 5.0) use version `9.0.0`\n* For Xcode 10 (Swift 4.2) use version `8.0.0`\n* For Xcode 9 (Swift 4) use version `7.1.0`\n* For Xcode 8 (Swift 3) use version `6.0.0`\n* For Xcode 7 (Swift 2) use version `4.1.0` or `5.2.0`\n* For Xcode 6.3 (Swift 1.2) use version `3.0.3`\n* For Xcode 6.1 and 6.2 (Swift 1.1) use version `2.2.0`\n\n## Demo Apps ##\n\n* Using [`Cocoa Pods`](https://github.com/ankurp/DollarPodApp)\n* Using [`Swift Package Manager`](https://github.com/ankurp/DollarSwiftPackage)\n* Using [`git submodule`](https://github.com/ankurp/DollarSubmoduleApp)\n\n## Communication ##\n\n- If you **need help**, use [gitter.im](https://gitter.im/ankurp/Dollar) or post a question on [Stack Overflow](http://stackoverflow.com/questions/tagged/dollar.swift) with tag `dollar.swift`.\n- If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/dollar.swift).\n- If you **found a bug**, open an issue.\n- If you **have a feature request**, open an issue.\n- If you **want to contribute**, submit a pull request.\n\n# Dollar Usage #\n\n## Array ##\n\n### at - `Dollar.at`\n\nCreates an array of elements from the specified indexes, or keys, of the collection. Indexes may be specified as individual arguments or as arrays of indexes.\n\n```swift\nDollar.at([\"ant\", \"bat\", \"cat\", \"dog\", \"egg\"], indexes: 0, 2, 4) \n=\u003e [\"ant\", \"cat\", \"egg\"]\n```\n\n### chunk - `Dollar.chunk`\n\nCreates an array of elements split into groups the length of size. If array can’t be split evenly, the final chunk will be the remaining elements.\n\n```swift\nDollar.chunk([1, 2, 3, 4], size: 2)\n=\u003e [[1, 2], [3, 4]]\n\nDollar.chunk([1, 2, 3, 4], size: 3)\n=\u003e [[1, 2, 3], [4]]\n```\n\n### compact - `Dollar.compact`\n\nCreates an array with all nil values removed.\n\n```swift\nDollar.compact([3, nil, 4, 5]) \n=\u003e [3, 4, 5]\n\nDollar.compact([nil, nil]) as NSObject[] \n=\u003e []\n```\n\n### contains - `Dollar.contains`\n\nChecks if a given value is present in the array.\n\n```swift\nDollar.contains([1, 2, 3, 1, 2, 3], value: 2) \n=\u003e true\n\nDollar.contains([1, 2, 3, 1, 2, 3], value: 10) \n=\u003e false\n```\n\n### cycle - `Dollar.cycle`\n\nCycles through the array definetly or indefinetly passing each element into the callback function. The second parameter is to specify how many times to cycle through the array. If left out it will cycle indefinetly.\n\n```swift\nDollar.cycle([1, 2, 3], 2) {\n  print($0)\n}\n// Prints the following\n123123\n```\n\n### difference - `Dollar.difference`\n\nCreates an array excluding all values of the provided arrays\n\n```swift\nDollar.difference([1, 2, 3, 4, 5], [5, 2, 10]) \n=\u003e [1, 3, 4]\n```\n\n### each - `Dollar.each`\n\nPasses each element in the array to the callback\n\n```swift\nDollar.each([\"A\", \"B\"]) { \n  print(\"Value \\($0)\")\n}\n=\u003e [\"A\", \"B\"]\n\nDollar.each([\"A\", \"B\"]) { (index, elem) in\n  print(\"\\(index) - \\(elem)\")\n}\n=\u003e [\"0 - A\", \"1 - B\"]\n```\n\n### every - `Dollar.every`\n\nChecks if the given callback returns true value for all items in the array.\n\n```swift\nDollar.every([1, 2, 3, 4], callback: { $0 \u003c 20 }) \n=\u003e true\n\nDollar.every([1, 2, 3, 4]) { $0 == 1 } \n=\u003e false\n```\n\n### factorial `Dollar.factorial`\n\nReturns factorial of integer\n\n```swift\nDollar.factorial(3)\n=\u003e 6\n\nDollar.factorial(0)\n=\u003e 1\n```\n\n### fetch - `Dollar.fetch`\n\nGet element from an array at the given index which can be negative to find elements from the end of the array. A default value can be returned if indexing out of bounds.\n\n\n```swift\nlet arr = [1, 2, 3, 4, 5, 6, 7, 8]\nDollar.fetch(arr, 100)\n=\u003e nil\n\nDollar.fetch(arr, 100, orElse: 42)\n=\u003e 42\n\nDollar.fetch(arr, -1)\n=\u003e 8\n```\n\n### fill - `Dollar.fill`\n\nFills elements of array with value from start up to, but not including, end. This method mutates array.\n\n```swift\nvar arr = Array\u003cInt\u003e(count: 5, repeatedValue: 1)\nDollar.fill(\u0026arr, withElem: 42)\n=\u003e [42, 42, 42, 42, 42]\n\nvar arr = Array\u003cInt\u003e(count: 5, repeatedValue: 1)\nDollar.fill(\u0026arr, withElem: 42, startIndex: 1, endIndex: 3)\n=\u003e [1, 42, 42, 42, 1]\n```\n\n\n### find - `Dollar.find`\n\nIterates over elements of an array and returning the first element that the callback returns true for.\n\n```swift\nDollar.find([1, 2, 3, 4], callback: { $0 == 2 }) \n=\u003e 2\n\nDollar.find([1, 2, 3, 4]) { $0 == 10 } \n=\u003e nil\n```\n\n### findIndex - `Dollar.findIndex`\n\nThis method is like find except that it returns the index of the first element that passes the callback check.\n\n```swift\nlet arr = [[\"age\": 36], [\"age\": 40], [\"age\": 1]]\nlet result = Dollar.findIndex(arr) { $0[\"age\"] \u003c 20 }\nresult \n=\u003e 2\n```\n\n### findLastIndex - `Dollar.findLastIndex`\n\nThis method is like findIndex except that it iterates over elements of the array from right to left.\n\n```swift\nlet arr = [[\"age\": 36], [\"age\": 40], [\"age\": 1]]\nlet result = Dollar.findLastIndex(arr) { $0[\"age\"] \u003e 30 }\nresult\n=\u003e 1\n```\n\n### first - `Dollar.first(array: AnyObject[])`\n\nGets the first element in the array.\n\n```swift\nDollar.first([1, 2, 3, 4])\n=\u003e 1\n\nDollar.first([]) \n=\u003e nil\n```\n### groupBy `Dollar.groupBy`\n\nThis method returns a dictionary of values grouped by the value returned by a callback.\n\n``` swift\nDollar.groupBy([1, 2, 3, 4, 5], callback: {$0 % 2})\n=\u003e [0: [2, 4], 1: [1, 3]]\n\nDollar.groupBy([\"strings\", \"with\", \"different\", lengths\"], callback: {$0.characters.count})\n=\u003e [7: [\"strings\", \"lengths\"], 9: [\"different\"], 4: [\"With\"]]\n```\n\n### second - `Dollar.second(array: AnyObject[])`\n\nGets the second element in the array.\n\n```swift\nDollar.second([1, 2, 3, 4])\n=\u003e 2\n\nDollar.second([1]) \n=\u003e nil\n\nDollar.second([])\n=\u003e nil\n```\n\n### flatMap - `Dollar.flatMap`\n\nMaps a function that converts elements to a list and then concatenates them.\n\n```swift\nlet values = [2, 3, 4, 5, 6, 7]\nDollar.flatMap(values) { [$0, $0] }\n=\u003e [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]\n```\n\n### flatMap - `Dollar.flatMap`\n\nMaps a function that converts a type to an Optional over an Optional, and then returns a single-level Optional.\n\n\n```swift\nlet url = NSURL(string: \"https://apple.com/swift\")\nDollar.flatMap(url) { $0.lastPathComponent }\n=\u003e Optional(\"swift\")\n```\n\n*Note*: This is the same behavior as Optional chaining.\nThe code above translates to\n```swift\nNSURL(string: \"https://apple.com/swift/\")?.lastPathComponent\n=\u003e Optional(\"swift\")\n```\n\n### flatten - `Dollar.flatten`\n\nFlattens a nested array of any depth.\n\n```swift\nDollar.flatten([[3], 4, 5]) as Int[] \n=\u003e [3, 4, 5]\n\nDollar.flatten([[3], \"Hello\", 5]) as NSObject[] \n=\u003e [3, \"Hello\", 5]\n\nDollar.flatten([[[3], 4], 5]) as Int[] \n=\u003e [3, 4, 5]\n```\n\n### frequencies - `Dollar.frequencies`\nThis method returns a dictionary of values in an array mapping to the total number of occurrences in the array. If passed a function it returns a frequency table of the results of the given function on the arrays elements.\n\n```swift\nDollar.frequencies([\"a\", \"a\", \"b\", \"c\", \"a\", \"b\"]) \n=\u003e [\"a\": 3, \"b\": 2, \"c\": 1]\n\nDollar.frequencies([1, 2, 3, 4, 5]) { $0 % 2 == 0 }\n=\u003e [false: 3, true: 2]\n```\n\n### gcd `Dollar.gcd`\n\nGCD function return greatest common denominator with number passed\n\n```swift\nDollar.gcd(3, 10)\n=\u003e 1\n\nDollar.gcd(3, 9)\n=\u003e 3\n```\n\n### indexOf - `Dollar.indexOf`\n\nGets the index at which the first occurrence of value is found.\n\n```swift\nDollar.indexOf([1, 2, 3, 1, 2, 3], value: 2) \n=\u003e 1\n\nDollar.indexOf([\"A\", \"B\", \"C\"], value: \"B\") \n=\u003e 1\n\nDollar.indexOf([3, 4, 5], value: 5) \n=\u003e 2\n\nDollar.indexOf([3, 4, 5], value: 3) \n=\u003e 0\n\nDollar.indexOf([3, 4, 5], value: 2) \n=\u003e nil\n```\n\n### initial - `Dollar.initial`\n\nGets all but the last element or last n elements of an array.\n\n```swift\nDollar.initial([3, 4, 5]) \n=\u003e [3, 4]\n\nDollar.initial([3, 4, 5], numElements: 2) \n=\u003e [3]\n```\n\n### intersection - `Dollar.intersection`\n\nCreates an array of unique values present in all provided arrays.\n\n```swift\nDollar.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]) \n=\u003e [1, 2]\n```\n\n### it-isIn `Dollar.it\u003cT: Comparable\u003e(i: T, isIn range: Range\u003cT\u003e)`\n\nReturns true if i is in interval or range\n\n```swift\nDollar.it(\"c\", isIn: \"a\"...\"z\")\n=\u003e true\n\nDollar.it(\"z\", isIn: \"a\"..\u003c\"z\")\n=\u003e false\n\nDollar.it(1, isIn: -1.0...10.0)\n=\u003e true\n```\n\n### last - `Dollar.last`\n\nGets the last element from the array.\n\n```swift\nDollar.last([3, 4, 5]) \n=\u003e 5\n```\n\n### lastIndexOf - `Dollar.lastIndexOf`\n\nGets the index at which the last occurrence of value is found.\n\n```swift\nDollar.lastIndexOf([1, 2, 3, 1, 2, 3], value: 2) \n=\u003e 4\n```\n\n### lcm `Dollar.lcm`\n\nLCM method return least common multiple with number passed\n\n```swift\nDollar.lcm(3, 10)\n=\u003e 30\n\nDollar.lcm(3, 9)\n=\u003e 9\n```\n\n### rest - `Dollar.rest`\n\nThe opposite of initial this method gets all but the first element or first n elements of an array.\n\n```swift\nDollar.rest([3, 4, 5]) \n=\u003e [4, 5]\n\nDollar.rest([3, 4, 5], numElements: 2) \n=\u003e [5]\n```\n\n### map - `Dollar.map`\n\nMaps each element to new value based on the map function passed\n\n```swift\nDollar.map([1, 2, 3, 4]) { \n  $0 * 2\n}\n=\u003e [2, 4, 6, 8]\n```\n\n### min - `Dollar.min`\n\nRetrieves the minimum value in an array.\n\n```swift\nDollar.min([2, 1, 2, 3, 4]) \n=\u003e 1\n```\n\n### max - `Dollar.max`\n\nRetrieves the maximum value in an array.\n\n```swift\nDollar.max([1, 2, 3, 4, 2, 1]) \n=\u003e 4\n```\n\n### pluck - `Dollar.pluck`\n\nRetrieves the value of a specified property from all elements in the array.\n\n```swift\nlet arr = [[\"age\": 20], [\"age\": 30], [\"age\": 40]]\nDollar.pluck(arr, value: \"age\") \n=\u003e [20, 30, 40]\n```\n\n### pull - `Dollar.pull`\n\nRemoves all provided values from the given array.\n\n```swift\nDollar.pull([3, 4, 5, 3, 5], values: 3, 5) \n=\u003e [4]\n\nDollar.pull([3, 4, 5, 3, 5], values: 4) \n=\u003e [3, 5, 3, 5]\n\nDollar.pull([3, 4, 5, 3, 5], values: 3, 4, 5) \n=\u003e []\n```\n\n### pullAt - `Dollar.pullAt`\n\nRemoves all provided values from the given array at the given indices\n\n```swift\nlet arr = [10, 20, 30, 40, 50]\nDollar.pullAt(arr, indices: 1, 2, 3)\n```\n\n### range - `Dollar.range`\n\nCreates an array of numbers (positive and/or negative) progressing from start up to but not including end.\n\n```swift\nDollar.range(4) \n=\u003e [0, 1, 2, 3]\n\nDollar.range(from: 1, to: 5) \n=\u003e [1, 2, 3, 4]\n\nDollar.range(from: 0, to: 20, incrementBy: 5) \n=\u003e [0, 5, 10, 15]\n\nDollar.range(from: 1, through: 5)\n=\u003e [1, 2, 3, 4, 5]\n\nDollar.range(from: 0, through: 20, incrementBy: 5)\n=\u003e [0, 5, 10, 15, 20]\n```\n\n### reduce - `Dollar.reduce`\n\nReduce function that will resolve to one value after performing combine function on all elements\n\n```swift\nDollar.reduce([1, 2, 3], initial: 0) { (total, element) in\n    total + element\n}\n=\u003e 6\n```\n\n### sample - `Dollar.sample`\n\nReturns a sample item from the array\n\n```swift\nlet arr: [Int] = [2, 1, 2, 3, 4]\nDollar.contains(arr, value: Dollar.sample(arr))\n=\u003e true\n```\n\n### sequence - `Dollar.sequence`\n\nCreates an array of an arbitrary sequence. Especially useful with builtin ranges.\n\n```swift\nDollar.sequence(0..4) \n=\u003e [0, 1, 2, 3]\n\nDollar.sequence(-2.0..2.0) \n=\u003e [-2.0, -1.0, 0.0, 1.0]\n\nDollar.sequence((0..20).by(5)) \n=\u003e [0, 5, 10, 15]\n\nDollar.sequence(\"abc\") \n=\u003e [\"a\", \"b\", \"c\"]\n```\n### remove - `Dollar.remove`\n\nRemoves an element from array.\n```swift\nDollar.remove([\"A\", \"B\", \"C\", \"D\"], value: \"B\")\n=\u003e [\"A\", \"C\", \"D\"]\n```\n\n### remove - `Dollar.remove`\n\nRemoves all elements from an array that the `callback` returns true.\n\n```swift\nlet result = Dollar.remove([1, 2, 3, 4, 5, 6]) { \n  $0 == 2 || $0 == 3 \n}\nresult\n=\u003e [1, 4, 5, 6]\n```\n\n### shuffle - `Dollar.shuffle`\n\nShuffles and returns the new shuffled array\n\n```swift\nlet result = Dollar.shuffle([1, 2, 3, 4, 5, 6])\nresult\n=\u003e [4, 1, 3, 5, 6, 2]\n```\n\n### size - `Dollar.size`\n\nReturns size of the array\n\n```swift\nDollar.size([\"a\", \"b\", \"c\")\n=\u003e 3\n```\n\n### sortedIndex - `Dollar.sortedIndex`\n\nGives the smallest index at which a value should be inserted into a given the array is sorted.\n\n```swift\nDollar.sortedIndex([3, 4, 6, 10], value: 5)\n=\u003e 2\n\nDollar.sortedIndex([10, 20, 30, 50], value: 40)\n=\u003e 3\n```\n\n### transpose - `Dollar.transpose`\n\nCreates a tranposed matrix.\n\n```swift\nDollar.transpose([[1, 2, 3], [4, 5, 6]])\n=\u003e [[1, 4], [2, 5], [3, 6]]\n```\n\n### union - `Dollar.union`\n\nCreates an array of unique values, in order, of the provided arrays.\n\n```swift\nDollar.union([1, 2, 3], [5, 2, 1, 4], [2, 1]) \n=\u003e [1, 2, 3, 5, 4]\n```\n\n### merge - `Dollar.merge`\n\nCreates an array of all values, including duplicates, of the arrays in the order they are provided.\n\n```swift\nlet arr = [1, 5]\nlet arr2 = [2, 4]\nlet arr3 = [5, 6]\nlet result = Dollar.merge(arr, arr2, arr3)\nresult\n=\u003e [1, 5, 2, 4, 5, 6]\n```\n\n### uniq - `Dollar.uniq`\n\nCreates a duplicate-value-free version of an array.\n\n```swift\nDollar.uniq([1, 2, 1, 3, 1])\n=\u003e [1, 2, 3]\n\nDollar.uniq([1, 2.5, 3, 1.5, 2, 3.5]) {\n  floor($0)\n}\n=\u003e [1, 2.5, 3]\n```\n\n### without - `Dollar.without`\n\nCreates an array excluding all provided values.\n\n```swift\nDollar.without([3, 4, 5, 3, 5], values: 3, 5)\n=\u003e [4]\n\nDollar.without([3, 4, 5, 3, 5], values: 4)\n=\u003e [3, 5, 3, 5]\n\nDollar.without([3, 4, 5, 3, 5], values: 3, 4, 5)\n=\u003e []\n```\n\n### xor - `Dollar.xor`\n\nCreates an array that is the symmetric difference of the provided arrays.\n\n```swift\nDollar.xor([1, 2, 3], [5, 2, 1, 4])\n=\u003e [3, 4, 5]\n```\n\n### zip - `Dollar.zip`\n\nCreates an array of grouped elements, the first of which contains the first elements of the given arrays.\n\n```swift\nDollar.zip([\"fred\", \"barney\"], [30, 40], [true, false]) as [NSObject] \n=\u003e [[\"fred\", 30, true], [\"barney\", 40, false]]\n```\n\n### zipObject - `Dollar.zipObject`\n\nCreates an object composed from arrays of keys and values.\n\n```swift\nDollar.zipObject([\"fred\", \"barney\"], values: [30, 40])\n=\u003e [\"fred\": 30, \"barney\": 40]\n```\n\n### partition - `Dollar.partition`\n\nProduces an array of arrays, each containing n elements, each offset by step. Stops after a partition is less than n length.\n\n```swift\nlet arr = [1, 2, 3, 4, 5]\nDollar.partition(arr, n: 2)\n=\u003e [[1, 2], [3, 4]]\n\nDollar.partition(arr, n: 4, step: 1)\n=\u003e [[1, 2, 3, 4], [2, 3, 4, 5]]\n\nDollar.partition(arr, n: 4, step: 1, pad: nil)\n=\u003e [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5]]\n\nDollar.partition(arr, n: 4, step: 1, pad: [6, 7, 8])\n=\u003e [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]\n```\n\n### partitionAll - `Dollar.partitionAll`\n\nProduces an array of arrays, each containing n elements, each offset by step. Continues after a partition is less than n length.\n\n```swift\nDollar.partitionAll([1, 2, 3, 4, 5], n: 4, step: 1)\n=\u003e [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5]]\n```\n\n### partitionBy - `Dollar.partitionBy`\n\nApplies a function to each element in array, splitting it each time the function returns a new value.\n\n```swift\nDollar.partitionBy([1, 2, 3, 4, 5]) { $0 % 2 == 0 }\n=\u003e [[1], [2, 4], [3, 5], [6]]\n\nDollar.partitionBy([1, 7, 3, 6, 10, 12]) { $0 % 3 }\n=\u003e [[1, 7], [3, 6], [10], [12]]\n```\n\n## Dictionary ##\n\n### keys - `Dollar.keys`\n\nCreates an array of keys given a dictionary.\n\n```swift\nDollar.keys([\"Dog\": 1, \"Cat\": 2])\n=\u003e [\"Dog\", \"Cat\"]\n```\n\n### values - `Dollar.values`\n\nCreates an array of values given a dictionary\n\n```swift\nDollar.values([\"Dog\": 1, \"Cat\": 2])\n=\u003e [1, 2]\n```\n\n### merge - `Dollar.merge`\n\nMerges all of the dictionaries together and the latter dictionary overrides the value at a given key\n\n```swift\nlet dict: Dictionary\u003cString, Int\u003e = [\"Dog\": 1, \"Cat\": 2]\nlet dict2: Dictionary\u003cString, Int\u003e = [\"Cow\": 3]\nlet dict3: Dictionary\u003cString, Int\u003e = [\"Sheep\": 4]\nDollar.merge(dict, dict2, dict3)\n=\u003e [\"Dog\": 1, \"Cat\": 2, \"Cow\": 3, \"Sheep\": 4]\n```\n\n### pick - `Dollar.pick`\n\nCreates a shallow clone of a dictionary composed of the specified keys.\n\n```swift\nDollar.pick([\"Dog\": 1, \"Cat\": 2, \"Cow\": 3], keys: \"Dog\", \"Cow\")\n=\u003e [\"Dog\": 1, \"Cow\": 3]\n```\n\n### omit - `Dollar.omit`\n\nCreates a shallow clone of a dictionary excluding the specified keys.\n\n```swift\nDollar.omit([\"Dog\": 1, \"Cat\": 2, \"Cow\": 3, \"Sheep\": 4], keys: \"Cat\", \"Dog\")\n=\u003e [\"Cow\": 3, \"Sheep\": 4]\n```\n\n## Object ##\n\n### tap - `Dollar.tap`\n\nInvokes interceptor with the object and then returns object.\n\n```swift\nvar beatle = Car(name: \"Fusca\")\nDollar.tap(beatle, {$0.name = \"Beatle\"}).color = \"Blue\"\n```\n\n## Function ##\n\n### after - `Dollar.after`\n\nCreates a function that executes passed function only after being called n times.\n\n```swift\nvar saves = [\"profile\", \"settings\"];\nlet asyncSave = { (function: () -\u003e ()?) in\n   function() \n   // Saving right away for testing \n   // but in real world would be async\n}\nvar isDone = false\nvar completeCallback = Dollar.after(saves.count) {\n   isDone = true\n}\nfor elem in saves {\n   asyncSave(completeCallback)\n}\nisDone \n=\u003e true\n```\n\n### bind - `Dollar.bind`\n\nCreates a function that, when called, invokes func with the binding of arguments provided.\n\n```swift\nvar helloWorldFunc = Dollar.bind({(T...) in\n  T[0] + \" \" + T[1] + \" from \" + T[2] \n}, \"Hello\", \"World\", \"Swift\")\nhelloWorldFunc() \n=\u003e \"Hello World from Swift\"\n\nhelloWorldFunc = Dollar.bind({ $0 + \" World\" }, \"Hello\")\nhelloWorldFunc()\n=\u003e \"Hello World\"\n\nhelloWorldFunc = Dollar.bind({ $0 + $1 + \" World\" }, \"Hello \", \"Great\")\nhelloWorldFunc()\n=\u003e \"Hello Great World\"\n```\n\n### compose - `Dollar.compose`\n\nCompose two or more functions where the return value of the first function is passed into the next function. Useful when chaining functions and returns a function that can be called with variadic argument values or an array of values as input\n\n```swift\nlet double = { (params: Int...) -\u003e [Int] in\n  return Dollar.map(params) { $0 * 2 }\n}\nlet subtractTen = { (params: Int...) -\u003e [Int] in\n  return Dollar.map(params) { $0 - 10 }\n}\nlet doubleSubtractTen = Dollar.compose(double, subtractTen)\ndoubleSubtractTen(5, 6, 7)\n=\u003e [0, 2, 4]\n\nlet f = Dollar.compose({ (arr: [Int]) -\u003e [Int] in\n  Dollar.map(arr) { $0 + 1 }\n}, { (arr: [Int]) -\u003e [Int] in\n  Dollar.map(arr) { $0 * 2 }\n})\nf([1, 2])\n=\u003e [4, 6]\n```\n\n### curry - `Dollar.curry`\n\nReturns a function which when invoked either executes the function returning its result, if all function arguments have been provided, or returns another function that accepts one more argument of the remaining function arguments until all arguments are supplied. This is useful for making partial function as seen in these examples.\n\n```swift\nfunc adder(x: Int, y: Int, z: Int) -\u003e Int {\nreturn x + y + z\n}\n\nlet curriedAdder = Dollar.curry(adder)\nlet addTenAnd = curriedAdder(10)\nlet addThirtyAnd = addTenAnd(20)\naddThirtyAnd(1)\n=\u003e 31\n\naddThirtyAnd(50)\n=\u003e 80\n\naddTenAnd(10)(10)\n=\u003e 30\n```\n\n### id - `Dollar.id`\n\nThe identify function which simply returns the argument its given.\n\n```swift\nDollar.id(\"Hello World from Swift\")\n=\u003e \"Hello World from Swift\"\n```\n\n### memoize - `Dollar.memoize`\n\nReturns a memoized function to improve performance by caching recursive function values.\n\n```swift\nvar times = 0 // to test memoization\n\nlet fibMemo = Dollar.memoize { (fib: (Int -\u003e Int), val: Int) -\u003e Int in\n  times += 1\n  return val == 1 || val == 0 ? 1 : fib(val - 1) + fib(val - 2)\n}\n\nlet x = fibMemo(5)\ntimes\n=\u003e 6\n\ntimes = 0\nlet y = fibMemo(5)\ntimes\n=\u003e 0\n\ntimes = 0\nlet z = fibMemo(6)\ntimes\n=\u003e 1\n```\n\n### noop - `Dollar.noop`\n\nA no-operation function.\n\n```swift\nDollar.noop() \n=\u003e nil\n```\n\n### now - `Dollar.now`\n\nGets the number of seconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC).\n\n```swift\nDollar.now() \n=\u003e 1431911564.292577\n```\n\n### once - `Dollar.once`\n\nGet a wrapper function that executes the passed function only once. Useful for getting shared config or creating singleton objects.\n\n```swift\nfunc createConfig() -\u003e [String: String] {\n  var i = 1\n  return [\n    \"App ID\": \"\\(i++)\",\n    \"URL\": \"https://someurl\"\n  ]\n}\n\nlet getConfig = Dollar.once(createConfig)\ngetConfig()\n=\u003e [\"App ID\": \"1\", \"URL\": \"https://someurl\"]\n\ngetConfig()\n=\u003e [\"App ID\": \"1\", \"URL\": \"https://someurl\"]\n```\n\n### partial - `Dollar.partial`\n\nCreates a function that, when called, invokes func with any additional partial arguments prepended to those provided to the new function.\n\n```swift\nlet partialFunc = Dollar.partial({(T...) in \n  T[0] + \" \" + T[1] + \" from \" + T[2] \n}, \"Hello\")\npartialFunc(\"World\", \"Swift\") \n=\u003e \"Hello World from Swift\"\n```\n\n### times - `Dollar.times`\n\nCall a function n times and also passes the index. If a value is returned in the function then the times method will return an array of those values.\n\n```swift\nlet fun = Dollar.bind({ (names: String...) -\u003e String in\n   let people = Dollar.join(names, separator: \" from \")\n   return \"Hello \\(people)\"\n   }, \"Ankur\", \"Swift\")\nDollar.times(2, function: fun) as String[] \n=\u003e [\"Hello Ankur from Swift\", \"Hello Ankur from Swift\"]\n```\n\n## Chaining ##\n\n**`Dollar.chain(...)`**\n\n### `any`\n\nReturns true if callback function returns true for at least one element in the array\n\n```swift\nvar chain = Dollar.chain([1, 2, 3])\nchain.any({ ($0 as Int) \u003c 2 })\n=\u003e true\n```\n\n### `all`\n\nReturns true if callback function returns true for all elements in the array\n\n```swift\nvar chain = Dollar.chain([1, 2, 3])\nchain.all({ ($0 as Int) \u003c 10 })\n=\u003e true\n```\n\n### `each`\n\nPasses each element value to the callback function\n\n```swift\nvar chain = Dollar.chain([\"Hello\", \"World\"])\nvar strBuilder = \"\"\nchain.each({ strBuilder += ($0 as String) }).value\nstrBuilder\n=\u003e \"HelloWorld\"\n```\n\n### `filter`\n\nFilters the arrary to elements for which the callback function returns true\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.filter({ ($0 as Int) \u003c 3 }).value\n=\u003e [1, 2]\n```\n\n### `first`\n\nReturns the first element in the array and terminates the chain\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.first()\n=\u003e 1\n```\n\n### `second`\n\nReturns the second element in the array and terminates the chain\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.second()\n=\u003e 2\n```\n\n### `third`\n\nReturns the third element in the array and terminates the chain\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.third()\n=\u003e 3\n```\n\n### `flatten`\n\nFlattens a nested array of any depth.\n\n```swift\nvar chain = Dollar.chain([[1, [2]], [3], 4])\nchain.flatten().value\n=\u003e [1, 2, 3, 4]\n```\n\n### `initial`\n\nGets all but the last element or last n elements of an array.\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.initial(2).value\n=\u003e [1, 2]\n```\n\n### `map`\n\nMaps each element to the new value returned in the callback function\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.map({ ($0 as Int) * 2 }).value\n=\u003e [2, 4, 6, 8]\n```\n\n### `size`\n\nReturns size of the array and terminates the chain\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4])\nchain.map({ ($0 as Int) * 2 }).size()\n=\u003e 4\n```\n\n### `slice`\n\nSlices the array based on the start and end position. If an end position is not specified it will slice till the end of the array.\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4, 5, 6, 7])\nchain.slice(2, end: 4).value\n=\u003e [3, 4]\n```\n\n### `value`\n\nReturns the value after evaluating all callbacks\n\n```swift\nvar chain = Dollar.chain([1, 2, 3, 4, 5, 6, 7])\nchain.value\n=\u003e [1, 2, 3, 4, 5, 6, 7]\n```\n\n**Chaining more than one method**\n\n```swift\nDollar.chain([[1, 2], 3, [[4], 5]])\n  .initial()\n  .flatten()\n  .first()\n=\u003e 1\n\nDollar.chain([1, 2, 3, 4, 5])\n  .filter { $0 % 1 == 0 }\n  .map { $0 * 2 }\n  .all { $0 \u003c 10}\n=\u003e false\n\nDollar.chain([1, 2, 3, 4, 5])\n  .map { $0 * 2 }\n  .flatten()\n  .initial(2).value\n=\u003e [2, 4, 6]\n```\n\n# Cent Usage #\n\n## Array Extensions ##\n\n### `\u003c\u003c elem: Element -\u003e [Element]`\n\nOverloaded operator to append element to an array or append elements from another array into the first array. Return array with the element appended in the end.\n\n```swift\nvar array = [1, 2, 3]\narray \u003c\u003c 4\n=\u003e [1, 2, 3, 4]\narray \u003c\u003c [5, 6]\n=\u003e [1, 2, 3, 4, 5, 6]\n```\n\n### `at(indexes: Int...) -\u003e [Element]`\n\nCreates an array of elements from the specified indexes, or keys, of the collection.\n\n```swift\nlet array = [\"foo\", \"spam\", \"bar\", \"eggs\"]\nlet some = array.at(1, 3)\n=\u003e [\"spam\", \"eggs\"]\n```\n\n### `each(callback: (Element) -\u003e ()) -\u003e [Element]`\n\nFor each item in the array invoke the callback by passing the elem\n\n```swift\nlet array = [\"foo\", \"spam\", \"bar\", \"eggs\"]\narray.each {\n  print($0)\n}\n=\u003e [\"foo\", \"spam\", \"bar\", \"eggs\"]\n```\n\n### `eachWithIndex(callback: (Int, Element) -\u003e ()) -\u003e [Element]`\n\nFor each item in the array invoke the callback by passing the elem along with the index\n\n```swift\nlet array = [\"foo\", \"spam\", \"bar\", \"eggs\"]\narray.each { (index, elem)\n  print(\"\\(index) - \\(elem)\")\n}\n=\u003e [\"foo\", \"spam\", \"bar\", \"eggs\"]\n```\n\n### `cycle\u003cU\u003e(times: Int, callback: (Element) -\u003e U)`\n\nCycles through the array definetly or indefinetly passing each element into the callback function. The second parameter is to specify how many times to cycle through the array. If left out it will cycle indefinetly.\n\n```swift\n[1, 2, 3].cycle(2) {\n  print($0)\n}\n// Prints the following\n123123\n\n[1, 2, 3].cycle {\n  print($0)\n}\n// Cycles in an infinite loop\n```\n\n### `every(callback: (Element) -\u003e Bool) -\u003e Bool`\n\nChecks if the given callback returns true value for all items in the array.\n\n```swift\n[\"angry\", \"hungry\"].every { (a: String) -\u003e (Bool) in \n  a.hasSuffix(\"gry\") \n}\n=\u003e true\n```\n\n### `indexOf\u003cT: Equatable\u003e(value: T) -\u003e Int`\n\nGets the index at which the first occurrence of value is found.\n\n```swift\nlet array = [\"foo\", \"spam\", \"bar\", \"eggs\"]\narray.indexOf(\"spam\")\n=\u003e 1\narray.indexOf(\"None\")\n=\u003e nil\n```\n\n### `fetch(index: Int, orElse: T? = .None) -\u003e T!`\n\nGet element from an array at the given index which can be negative to find elements from the end of the array. A default value can be returned if indexing out of bounds.\n\n\n```swift\nlet arr = [1, 2, 3, 4, 5, 6, 7, 8]\narr.fetch(100)\n=\u003e nil\n\narr.fetch(100, orElse: 42)\n=\u003e 42\n\narr.fetch(-1)\n=\u003e 8\n```\n\n### `findIndex(callback: (Element) -\u003e Bool) -\u003e Int?`\n\nThis method is like find except that it returns the index of the first element that passes the callback check.\n\n```swift\nlet ind: int? = [\"foo\", \"bar\", \"spam\", \"eggs\"].findIndex {\n  $0.length == 4\n}\nind! == 2 \n=\u003e true\n```\n\n### `findLastIndex(callback: (Element) -\u003e Bool) -\u003e Int?`\n\nThis method is like findIndex except that it iterates over elements of the array from right to left.\n\n```swift\nlet ind: int? = [\"foo\", \"bar\", \"spam\", \"eggs\"].findLastIndex {\n  $0.length == 4 \n}\nind! == 3 \n=\u003e true\n```\n\n### `first() -\u003e Element?`\n\nGets the first element in the array.\n\n```swift\nlet first = [\"foo\", \"bar\"].first()\n=\u003e \"foo\"\n```\n\n### `flatten() -\u003e [Element]`\n\nFlattens a nested array of any depth.\n\n```swift\nlet unFlattened = [\"foo\", [\"bar\"], [[\"spam\"]], [[[\"eggs\"]]] ]\nlet flattened = unFlattened.flatten() \n=\u003e [\"foo\", \"bar\", \"spam\", \"eggs\"]\n```\n\n### `get(index: Int) -\u003e Element?`\n\nGet element at index\n\n```swift\nlet element = [\"foo\", \"bar\"].get(0)\nelement!\n=\u003e \"foo\"\n\nlet nothing = [\"foo\", \"bar\"].get(1000)\n=\u003e nil\n```\n\n### `initial(numElements: Int? = 1) -\u003e [Element]`\n\nGets all but the last element or last n elements of an array.\n\n```swift\nlet initial = [\"foo\", \"bar\", \"spam\"].initial(2) \n=\u003e [\"foo\"]\n```\n\n### `last() -\u003e Element?`\n\nGets the last element from the array.\n\n```swift\nlet last = [\"foo\", \"bar\"].last() \n=\u003e \"bar\"\n```\n\n### `rest(numElements: Int? = 1) -\u003e [Element]`\n\nThe opposite of initial this method gets all but the first element or first n elements of an array.\n\n```swift\nlet rest = [\"foo\", \"bar\", \"spam\"].rest(2)\n=\u003e [\"spam\"]\n```\n\n### `min\u003cT: Comparable\u003e() -\u003e T?`\n\nRetrieves the minimum value in an array.\n\n```swift\nlet min = [ 0, 1, 2 ].min()\n=\u003e 0\n```\n\n### `max\u003cT: Comparable\u003e() -\u003e T?`\n\nRetrieves the maximum value in an array.\n\n```swift\nlet max = [ 0, 1, 2].max()\n=\u003e 2\n```\n\n### `remove\u003cT: Equatable\u003e(value: T) -\u003e T?`\n\nRemove element from array\n\n```swift\nvar arr = [\"A\", \"B\", \"C\", \"D\", \"E\"]\narr.remove(\"B\")\n=\u003e [\"A\", \"C\", \"D\", \"E\"]\n```\n\n### `contains\u003cT:Equatable\u003e(value: T) -\u003e Bool`\n\nChecks if a given value is present in the array.\n\n```swift\nvar arr = [\"A\", \"B\", \"C\", \"D\", \"E\"]\narr.contains(\"C\")\n=\u003e true\narr.contains(\"Z\")\n=\u003e false\n```\n\n\n## Character Extensions ##\n\n### `\"A\".description -\u003e String`\n\nGet string description of Character\n\n```swift\nlet ch: Character = \"A\"\nlet str = ch.description\n=\u003e \"A\"\n```\n\n### `\"A\".ord -\u003e Int`\n\nGet int representation of character\n\n```swift\nCharacter(\"A\").ord\n=\u003e 65\n```\n\n\n## Date Extensions ##\n\n### `Date.from(#year: Int, month: Int, day: Int) -\u003e NSDate`\n\nReturns a new Date given the year month and day\n\n```swift\nlet date = Date.from(2014, 1, 1) \n=\u003e \"Jan 1, 2014, 12:00 AM\"\n```\n\n### `Date.from(#unix: Double) -\u003e NSDate`\n\nReturns a new Date given the unix timestamp (timeIntervalSince1970)\n\n```swift\nlet date = Date.from(unix: 1_388_552_400.0)\n=\u003e \"Jan 1, 2014, 12:00 AM\"\n```\n\n### `Date.parse(dateStr: String, format: String = \"yyyy-MM-dd\") -\u003e NSDate`\n\nParses the date based on the format and return a new Date\n\n```swift\nlet parsedDate = Date.parse(\"2014-01-01\", format: \"yyyy-MM-dd\")\n=\u003e \"Jan 1, 2014, 12:00 AM\"\n```\n\n### `Date.unix(date: NSDate = NSDate()) -\u003e Double`\n\nReturns the unix timestamp of the date passed in or the current unix timestamp\n\n```swift\nlet currentUnix = Date.unix()\n=\u003e 1,388,552,400.0\n\nvar otherNSDate = Date()\nlet otherUnix = Date.unix(otherDate)\n=\u003e 1,388,552,400.0\n```\n\n### `Int.hour.fromNow` et al.\n\nUse the following syntax to calculate dates and times based on the user's current calendar. \n\n```swift\n1.day.ago\n=\u003e \"Apr 10, 2015, 11:51 AM\"\n4.hours.fromNow\n=\u003e \"Apr 11, 2015, 3:51 PM\"\n```\n\n## Dictionary Extensions ##\n\n### `merge\u003cK, V\u003e(dictionaries: Dictionary\u003cK, V\u003e...)`\n\nMerges the dictionary with dictionaries passed. The latter dictionaries will override values of the keys that are already set\n\n```swift\nvar dic = [\"foo\": \"bar\"] \nlet anotherDic = [\"foo\": \"baz\", \"spam\": \"eggs\"]\ndic.merge(anotherDic)\n=\u003e [\"foo\": \"baz\", \"spam\": \"eggs\"]\n```\n\n## Int Extensions ##\n\n### `times(callback: (Int) -\u003e ())`\n\nInvoke a callback n times with callback that takes index\n\n```swift\n5.times { print(\"Na\") } \n=\u003e \"NaNaNaNaNa\"\n```\n\n### `times (function: () -\u003e ())`\n\nInvoke a callback n times\n\n```swift\n5.times { (a: Int) -\u003e () in print(\"\\(a) \") } \n=\u003e 0 1 2 3 4  \n```\n\n### `char -\u003e Character`\n\nGet ASCII character from integer\n\n```swift\n65.char\n=\u003e \"A\"\n```\n\n### `isEven`\n\nCheck if int is even\n\n```swift\n2.isEven\n=\u003e true\n\n1.isEven\n=\u003e false\n```\n\n### `isOdd`\n\nCheck if int is odd\n\n```swift\n3.isOdd\n=\u003e true\n\n2.isOdd\n=\u003e false\n```\n\n### `digits() -\u003e [Int]`\n\nSplits the int into array of digits\n\n```swift\n4208.digits()\n=\u003e [4, 2, 0, 8]\n```\n\n### `lcm() -\u003e Int`\n\nLCM method return least common multiple with number passed\n\n```swift\n3.lcm(10)\n=\u003e 30\n\n3.lcm(9)\n=\u003e 9\n```\n\n### `gcd() -\u003e Int`\n\nGCD method return greatest common denominator with number passed\n\n```swift\n3.gcd(10)\n=\u003e 1\n\n3.gcd(9)\n=\u003e 3\n```\n\n### `random() -\u003e Int`\n\nReturns random number from 0 upto but not including value of integer\n\n```swift\n3.random()\n=\u003e 2\n\n3.random()\n=\u003e 1\n```\n\n### `factorial() -\u003e Int`\n\nReturns factorial of integer\n\n```swift\n3.factorial()\n=\u003e 6\n\n0.factorial()\n=\u003e 1\n```\n\n### `isIn(interval) -\u003e Bool`\n\nReturns true if i is in interval or range\n\n```swift\n5.isIn(1...10)\n=\u003e true\n\n10.isIn(1..\u003c10)\n=\u003e false\n```\n\n### `next() -\u003e Int`\n\nGet the next int\n\n```swift\n10.next()\n=\u003e 11\n```\n\n### `prev() -\u003e Int`\n\nGet the previous int\n\n```swift\n10.prev()\n=\u003e 9\n```\n\n### `upTo(limit: Int, callback: () -\u003e ())`\n\nInvoke the callback from int up to and including limit\n\n```swift\n3.upTo(5) {\n  print(\"Hi\")\n}\nPrints \"HiHiHi\"\n```\n\n### `downTo(limit: Int, callback: () -\u003e ())`\n\nInvoke the callback from int down to and including limit\n\n```swift\n3.downTo(0) {\n  print(\"Hi\")\n}\nPrints \"HiHiHiHi\"\n```\n\n## String Extensions ##\n\n### `.length`\n\nGet the length of the string\n\n```swift\n\"Hello\".length\n=\u003e 5\n```\n\n### `.camelCase`\n\nGet the camel case representation of the string\n\n```swift\n\"__Dollar and cent-- dollarANDCent\".camelCase\n=\u003e \"dollarAndCentDollarAndCent\"\n```\n\n### `.kebabCase`\n\nGet the kebab case representation of the string\n\n```swift\n\"__Dollar and cent-- dollarANDCent\".kebabCase\n=\u003e \"dollar-and-cent-dollar-and-cent\"\n```\n\n### `.snakeCase`\n\nGet the snake case representation of the string\n\n```swift\n\"__Dollar and cent-- dollarANDCent\".snakeCase\n=\u003e \"dollar_and_cent_dollar_and_cent\"\n```\n\n### `.startCase`\n\nGet the start case representation of the string\n\n```swift\n\"__Dollar and cent-- dollarANDCent\".startCase\n=\u003e \"Dollar And Cent Dollar And Cent\"\n```\n\n### `=~ str: String -\u003e Bool`\n\nDoes a regex match of whether regex string on the right is matches the string on the left\n\n```swift\n\"Dollar\" =~ \"oll\"\n=\u003e true\n```\n\n### `* n: Int -\u003e String`\n\nGet string concatenated `n` times\n\n```swift\n\"Hi Swift! \" * 3\n=\u003e \"Hi Swift! Hi Swift! Hi Swift! \"\n```\n\n### `[i: Int] -\u003e Character?`\n\nGet character at a subscript\n\n```swift\n\"Hello World\"[6] == \"W\"\n=\u003e true\n\n\"Hi\"[5]\n=\u003e nil\n```\n\n### `[str: String] -\u003e String?`\n\nReturns the substring based on the first regex match passed in the subscript\n\n```swift\nlet proj = \"Dollar and Cent\"\nproj[\"^.+[^and Cent]\"]\n=\u003e {Some: \"Dollar\"}\n```\n\n\n### `[r: Range\u003cInt\u003e] -\u003e String`\n\nGet substring using subscript notation and by passing a range\n\n```swift\n\"Hello World\"[0..\u003c5] == \"Hello\" \n=\u003e true\n```\n\n### `indexOf(char: Character) -\u003e Int?`\n\nGet the start index of character\n\n```swift\n\"hello world\".indexOf(Character(\"o\"))!\n=\u003e 4\n```\n\n\n### `indexOf(str: String) -\u003e Int?`\n\nGet the start index of string\n\n```swift\n\"hello world\".indexOf(\"llo\")!\n=\u003e 2\n\n\"hello world\".indexOf(\"illo\")\n=\u003e nil\n```\n\n### `indexOf(pattern: String) -\u003e Int?`\n\nGet the start index of regex pattern inside the string\n\n```swift\n\"hello world\".indexOf(\".llo\")!\n=\u003e 1\n```\n\n### `split(delimiter: Character) -\u003e [String]`\n\nGet an array from string split using the delimiter character\n\n```swift\n\"Hello World\".split(\" \") \n=\u003e [\"Hello\", \"World\"]\n```\n\n### `lstrip() -\u003e String`\n\nGet string without leading spaces\n\n```swift\nlet leadingSpace = \"  Hello\"\nleadingSpace.lstrip()\n=\u003e \"Hello\"\n```\n\n### `rstrip() -\u003e String`\n\nGet string without trailing spaces\n\n```swift\nlet trailingSpace = \"Hello   \"\ntrailingSpace.rstrip()\n=\u003e \"Hello\"\n```\n\n### `strip() -\u003e String`\n\nGet string without leading or trailing spaces\n\n```swift\nlet spaces = \"   Hello   \"\nspaces.strip()\n=\u003e \"Hello\"\n```\n\n## Regex ##\n\n### `init`\n\nInit with regex pattern as string\n\n```swift\nRegex.init(\"^Hello.World$\") // Regex that matches \"Hello World\"\n```\n\n### `matches(testStr: String) -\u003e [AnyObject]`\n\nReturn matches based on String passed.\n\n```swift\nlet re = Regex.init(\"^Hello.World$\")\nre.matches(\"Hello World\")\n```\n\n### `test(testStr: String) -\u003e Bool`\n\n```swift\nlet re = Regex.init(\"^Hello.World$\")\nre.test(\"Hello World\")\n=\u003e true\n\nre.test(\"Str\")\n=\u003e false\n```\n\n### `escapeStr(str: String) -\u003e String`\n\nEscape string with regex characters\n\n```swift\nRegex.escape(\"Hello.World\")\n=\u003e \"Hello\\.World\"\n```\n\n## Range Extensions ##\n\n### equals - `==`\n\nCheck the equality of two ranges\n\n```swift\n(1...5) == (1...5) \n=\u003e true\n\n(1..\u003c5) == (1...5) \n=\u003e false\n```\n\n### `eachWithIndex(callback: (T) -\u003e ())`\n\nFor each index in the range invoke the callback by passing the item in range\n\n```swift\n(1...5).eachWithIndex { (a: Int) -\u003e () in print(\"\\(a)\") } \n=\u003e 12345\n```\n\n### `each(callback: () -\u003e ())`\n\nFor each index in the range invoke the callback\n\n```swift\n(1...5).each { print(\"Na\") } \n=\u003e \"NaNaNaNaNa\"\n```\n\n# Contributing #\nIf you are interested in contributing checkout [CONTRIBUTING.md](https://github.com/ankurp/Dollar/blob/master/CONTRIBUTING.md)\n","funding_links":[],"categories":["Data Structures / Algorithms","Libs","Swift","Functions \u0026 Operators","Utility [🔝](#readme)"],"sub_categories":["Getting Started","Utility","Other free courses","Linter"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankurp%2FDollar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fankurp%2FDollar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fankurp%2FDollar/lists"}