[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6896":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":16,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":21,"hasPages":21,"topics":22,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":31,"lastSyncTime":32,"discoverSource":33},6896,"Dollar","ankurp\u002FDollar","ankurp","A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript","https:\u002F\u002Fwww.dollarswift.org",null,"Swift",4241,362,97,3,0,59.68,"MIT License",false,"master",true,[23,24,25,26,27],"callback-returns","dollar","swift","swift-language","xcode","2026-06-12 04:00:30","Dollar ![CocoaPods](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fv\u002FDollar.svg) [![Reviewed by Hound](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReviewed_by-Hound-8E64B0.svg)](https:\u002F\u002Fhoundci.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:\u002F\u002Flodash.com) or [Underscore.js](http:\u002F\u002Funderscorejs.org) in Javascript.\n\n[Cent](https:\u002F\u002Fgithub.com\u002Fankurp\u002FCent) 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:\u002F\u002Fwww.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:\u002F\u002Fcocoapods.org\u002F) 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:\u002F\u002Fgithub.com\u002Fankurp\u002FDollarPodApp).\n\n## Using [Swift Package Manager](https:\u002F\u002Fgithub.com\u002Fapple\u002Fswift-package-manager)\n\nAdd the following dependency `.Package(url: \"https:\u002F\u002Fgithub.com\u002Fankurp\u002FDollar\", 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:\u002F\u002Fswift.org\n\n## Using `git submodule`\n\n1. If you are using git then add Dollar as a submodule using `git submodule add https:\u002F\u002Fgithub.com\u002Fankurp\u002FDollar.git`. If not using git download the project using `git clone https:\u002F\u002Fgithub.com\u002Fankurp\u002FDollar.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:\u002F\u002Frecordit.co\u002F0gQiCSEREF)\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:\u002F\u002Fgithub.com\u002Fankurp\u002FDollarPodApp)\n* Using [`Swift Package Manager`](https:\u002F\u002Fgithub.com\u002Fankurp\u002FDollarSwiftPackage)\n* Using [`git submodule`](https:\u002F\u002Fgithub.com\u002Fankurp\u002FDollarSubmoduleApp)\n\n## Communication ##\n\n- If you **need help**, use [gitter.im](https:\u002F\u002Fgitter.im\u002Fankurp\u002FDollar) or post a question on [Stack Overflow](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fdollar.swift) with tag `dollar.swift`.\n- If you'd like to **ask a general question**, use [Stack Overflow](http:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fdollar.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=> [\"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=> [[1, 2], [3, 4]]\n\nDollar.chunk([1, 2, 3, 4], size: 3)\n=> [[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=> [3, 4, 5]\n\nDollar.compact([nil, nil]) as NSObject[] \n=> []\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=> true\n\nDollar.contains([1, 2, 3, 1, 2, 3], value: 10) \n=> 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\u002F\u002F 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=> [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=> [\"A\", \"B\"]\n\nDollar.each([\"A\", \"B\"]) { (index, elem) in\n  print(\"\\(index) - \\(elem)\")\n}\n=> [\"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=> true\n\nDollar.every([1, 2, 3, 4]) { $0 == 1 } \n=> false\n```\n\n### factorial `Dollar.factorial`\n\nReturns factorial of integer\n\n```swift\nDollar.factorial(3)\n=> 6\n\nDollar.factorial(0)\n=> 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=> nil\n\nDollar.fetch(arr, 100, orElse: 42)\n=> 42\n\nDollar.fetch(arr, -1)\n=> 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>(count: 5, repeatedValue: 1)\nDollar.fill(&arr, withElem: 42)\n=> [42, 42, 42, 42, 42]\n\nvar arr = Array\u003CInt>(count: 5, repeatedValue: 1)\nDollar.fill(&arr, withElem: 42, startIndex: 1, endIndex: 3)\n=> [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=> 2\n\nDollar.find([1, 2, 3, 4]) { $0 == 10 } \n=> 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=> 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\"] > 30 }\nresult\n=> 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=> 1\n\nDollar.first([]) \n=> 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=> [0: [2, 4], 1: [1, 3]]\n\nDollar.groupBy([\"strings\", \"with\", \"different\", lengths\"], callback: {$0.characters.count})\n=> [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=> 2\n\nDollar.second([1]) \n=> nil\n\nDollar.second([])\n=> 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=> [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:\u002F\u002Fapple.com\u002Fswift\")\nDollar.flatMap(url) { $0.lastPathComponent }\n=> Optional(\"swift\")\n```\n\n*Note*: This is the same behavior as Optional chaining.\nThe code above translates to\n```swift\nNSURL(string: \"https:\u002F\u002Fapple.com\u002Fswift\u002F\")?.lastPathComponent\n=> 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=> [3, 4, 5]\n\nDollar.flatten([[3], \"Hello\", 5]) as NSObject[] \n=> [3, \"Hello\", 5]\n\nDollar.flatten([[[3], 4], 5]) as Int[] \n=> [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=> [\"a\": 3, \"b\": 2, \"c\": 1]\n\nDollar.frequencies([1, 2, 3, 4, 5]) { $0 % 2 == 0 }\n=> [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=> 1\n\nDollar.gcd(3, 9)\n=> 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=> 1\n\nDollar.indexOf([\"A\", \"B\", \"C\"], value: \"B\") \n=> 1\n\nDollar.indexOf([3, 4, 5], value: 5) \n=> 2\n\nDollar.indexOf([3, 4, 5], value: 3) \n=> 0\n\nDollar.indexOf([3, 4, 5], value: 2) \n=> 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=> [3, 4]\n\nDollar.initial([3, 4, 5], numElements: 2) \n=> [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=> [1, 2]\n```\n\n### it-isIn `Dollar.it\u003CT: Comparable>(i: T, isIn range: Range\u003CT>)`\n\nReturns true if i is in interval or range\n\n```swift\nDollar.it(\"c\", isIn: \"a\"...\"z\")\n=> true\n\nDollar.it(\"z\", isIn: \"a\"..\u003C\"z\")\n=> false\n\nDollar.it(1, isIn: -1.0...10.0)\n=> true\n```\n\n### last - `Dollar.last`\n\nGets the last element from the array.\n\n```swift\nDollar.last([3, 4, 5]) \n=> 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=> 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=> 30\n\nDollar.lcm(3, 9)\n=> 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=> [4, 5]\n\nDollar.rest([3, 4, 5], numElements: 2) \n=> [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=> [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=> 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=> 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=> [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=> [4]\n\nDollar.pull([3, 4, 5, 3, 5], values: 4) \n=> [3, 5, 3, 5]\n\nDollar.pull([3, 4, 5, 3, 5], values: 3, 4, 5) \n=> []\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\u002For negative) progressing from start up to but not including end.\n\n```swift\nDollar.range(4) \n=> [0, 1, 2, 3]\n\nDollar.range(from: 1, to: 5) \n=> [1, 2, 3, 4]\n\nDollar.range(from: 0, to: 20, incrementBy: 5) \n=> [0, 5, 10, 15]\n\nDollar.range(from: 1, through: 5)\n=> [1, 2, 3, 4, 5]\n\nDollar.range(from: 0, through: 20, incrementBy: 5)\n=> [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=> 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=> 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=> [0, 1, 2, 3]\n\nDollar.sequence(-2.0..2.0) \n=> [-2.0, -1.0, 0.0, 1.0]\n\nDollar.sequence((0..20).by(5)) \n=> [0, 5, 10, 15]\n\nDollar.sequence(\"abc\") \n=> [\"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=> [\"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=> [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=> [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=> 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=> 2\n\nDollar.sortedIndex([10, 20, 30, 50], value: 40)\n=> 3\n```\n\n### transpose - `Dollar.transpose`\n\nCreates a tranposed matrix.\n\n```swift\nDollar.transpose([[1, 2, 3], [4, 5, 6]])\n=> [[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=> [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=> [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=> [1, 2, 3]\n\nDollar.uniq([1, 2.5, 3, 1.5, 2, 3.5]) {\n  floor($0)\n}\n=> [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=> [4]\n\nDollar.without([3, 4, 5, 3, 5], values: 4)\n=> [3, 5, 3, 5]\n\nDollar.without([3, 4, 5, 3, 5], values: 3, 4, 5)\n=> []\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=> [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=> [[\"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=> [\"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=> [[1, 2], [3, 4]]\n\nDollar.partition(arr, n: 4, step: 1)\n=> [[1, 2, 3, 4], [2, 3, 4, 5]]\n\nDollar.partition(arr, n: 4, step: 1, pad: nil)\n=> [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5]]\n\nDollar.partition(arr, n: 4, step: 1, pad: [6, 7, 8])\n=> [[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=> [[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=> [[1], [2, 4], [3, 5], [6]]\n\nDollar.partitionBy([1, 7, 3, 6, 10, 12]) { $0 % 3 }\n=> [[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=> [\"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=> [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> = [\"Dog\": 1, \"Cat\": 2]\nlet dict2: Dictionary\u003CString, Int> = [\"Cow\": 3]\nlet dict3: Dictionary\u003CString, Int> = [\"Sheep\": 4]\nDollar.merge(dict, dict2, dict3)\n=> [\"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=> [\"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=> [\"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: () -> ()?) in\n   function() \n   \u002F\u002F Saving right away for testing \n   \u002F\u002F 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=> 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=> \"Hello World from Swift\"\n\nhelloWorldFunc = Dollar.bind({ $0 + \" World\" }, \"Hello\")\nhelloWorldFunc()\n=> \"Hello World\"\n\nhelloWorldFunc = Dollar.bind({ $0 + $1 + \" World\" }, \"Hello \", \"Great\")\nhelloWorldFunc()\n=> \"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...) -> [Int] in\n  return Dollar.map(params) { $0 * 2 }\n}\nlet subtractTen = { (params: Int...) -> [Int] in\n  return Dollar.map(params) { $0 - 10 }\n}\nlet doubleSubtractTen = Dollar.compose(double, subtractTen)\ndoubleSubtractTen(5, 6, 7)\n=> [0, 2, 4]\n\nlet f = Dollar.compose({ (arr: [Int]) -> [Int] in\n  Dollar.map(arr) { $0 + 1 }\n}, { (arr: [Int]) -> [Int] in\n  Dollar.map(arr) { $0 * 2 }\n})\nf([1, 2])\n=> [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) -> Int {\nreturn x + y + z\n}\n\nlet curriedAdder = Dollar.curry(adder)\nlet addTenAnd = curriedAdder(10)\nlet addThirtyAnd = addTenAnd(20)\naddThirtyAnd(1)\n=> 31\n\naddThirtyAnd(50)\n=> 80\n\naddTenAnd(10)(10)\n=> 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=> \"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 \u002F\u002F to test memoization\n\nlet fibMemo = Dollar.memoize { (fib: (Int -> Int), val: Int) -> 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=> 6\n\ntimes = 0\nlet y = fibMemo(5)\ntimes\n=> 0\n\ntimes = 0\nlet z = fibMemo(6)\ntimes\n=> 1\n```\n\n### noop - `Dollar.noop`\n\nA no-operation function.\n\n```swift\nDollar.noop() \n=> 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=> 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() -> [String: String] {\n  var i = 1\n  return [\n    \"App ID\": \"\\(i++)\",\n    \"URL\": \"https:\u002F\u002Fsomeurl\"\n  ]\n}\n\nlet getConfig = Dollar.once(createConfig)\ngetConfig()\n=> [\"App ID\": \"1\", \"URL\": \"https:\u002F\u002Fsomeurl\"]\n\ngetConfig()\n=> [\"App ID\": \"1\", \"URL\": \"https:\u002F\u002Fsomeurl\"]\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=> \"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...) -> 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=> [\"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=> 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=> 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=> \"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=> [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=> 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=> 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=> 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=> [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=> [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=> [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=> 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=> [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=> [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=> 1\n\nDollar.chain([1, 2, 3, 4, 5])\n  .filter { $0 % 1 == 0 }\n  .map { $0 * 2 }\n  .all { $0 \u003C 10}\n=> false\n\nDollar.chain([1, 2, 3, 4, 5])\n  .map { $0 * 2 }\n  .flatten()\n  .initial(2).value\n=> [2, 4, 6]\n```\n\n# Cent Usage #\n\n## Array Extensions ##\n\n### `\u003C\u003C elem: Element -> [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=> [1, 2, 3, 4]\narray \u003C\u003C [5, 6]\n=> [1, 2, 3, 4, 5, 6]\n```\n\n### `at(indexes: Int...) -> [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=> [\"spam\", \"eggs\"]\n```\n\n### `each(callback: (Element) -> ()) -> [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=> [\"foo\", \"spam\", \"bar\", \"eggs\"]\n```\n\n### `eachWithIndex(callback: (Int, Element) -> ()) -> [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=> [\"foo\", \"spam\", \"bar\", \"eggs\"]\n```\n\n### `cycle\u003CU>(times: Int, callback: (Element) -> 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\u002F\u002F Prints the following\n123123\n\n[1, 2, 3].cycle {\n  print($0)\n}\n\u002F\u002F Cycles in an infinite loop\n```\n\n### `every(callback: (Element) -> Bool) -> 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) -> (Bool) in \n  a.hasSuffix(\"gry\") \n}\n=> true\n```\n\n### `indexOf\u003CT: Equatable>(value: T) -> 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=> 1\narray.indexOf(\"None\")\n=> nil\n```\n\n### `fetch(index: Int, orElse: T? = .None) -> 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=> nil\n\narr.fetch(100, orElse: 42)\n=> 42\n\narr.fetch(-1)\n=> 8\n```\n\n### `findIndex(callback: (Element) -> Bool) -> 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=> true\n```\n\n### `findLastIndex(callback: (Element) -> Bool) -> 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=> true\n```\n\n### `first() -> Element?`\n\nGets the first element in the array.\n\n```swift\nlet first = [\"foo\", \"bar\"].first()\n=> \"foo\"\n```\n\n### `flatten() -> [Element]`\n\nFlattens a nested array of any depth.\n\n```swift\nlet unFlattened = [\"foo\", [\"bar\"], [[\"spam\"]], [[[\"eggs\"]]] ]\nlet flattened = unFlattened.flatten() \n=> [\"foo\", \"bar\", \"spam\", \"eggs\"]\n```\n\n### `get(index: Int) -> Element?`\n\nGet element at index\n\n```swift\nlet element = [\"foo\", \"bar\"].get(0)\nelement!\n=> \"foo\"\n\nlet nothing = [\"foo\", \"bar\"].get(1000)\n=> nil\n```\n\n### `initial(numElements: Int? = 1) -> [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=> [\"foo\"]\n```\n\n### `last() -> Element?`\n\nGets the last element from the array.\n\n```swift\nlet last = [\"foo\", \"bar\"].last() \n=> \"bar\"\n```\n\n### `rest(numElements: Int? = 1) -> [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=> [\"spam\"]\n```\n\n### `min\u003CT: Comparable>() -> T?`\n\nRetrieves the minimum value in an array.\n\n```swift\nlet min = [ 0, 1, 2 ].min()\n=> 0\n```\n\n### `max\u003CT: Comparable>() -> T?`\n\nRetrieves the maximum value in an array.\n\n```swift\nlet max = [ 0, 1, 2].max()\n=> 2\n```\n\n### `remove\u003CT: Equatable>(value: T) -> T?`\n\nRemove element from array\n\n```swift\nvar arr = [\"A\", \"B\", \"C\", \"D\", \"E\"]\narr.remove(\"B\")\n=> [\"A\", \"C\", \"D\", \"E\"]\n```\n\n### `contains\u003CT:Equatable>(value: T) -> 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=> true\narr.contains(\"Z\")\n=> false\n```\n\n\n## Character Extensions ##\n\n### `\"A\".description -> String`\n\nGet string description of Character\n\n```swift\nlet ch: Character = \"A\"\nlet str = ch.description\n=> \"A\"\n```\n\n### `\"A\".ord -> Int`\n\nGet int representation of character\n\n```swift\nCharacter(\"A\").ord\n=> 65\n```\n\n\n## Date Extensions ##\n\n### `Date.from(#year: Int, month: Int, day: Int) -> NSDate`\n\nReturns a new Date given the year month and day\n\n```swift\nlet date = Date.from(2014, 1, 1) \n=> \"Jan 1, 2014, 12:00 AM\"\n```\n\n### `Date.from(#unix: Double) -> 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=> \"Jan 1, 2014, 12:00 AM\"\n```\n\n### `Date.parse(dateStr: String, format: String = \"yyyy-MM-dd\") -> 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=> \"Jan 1, 2014, 12:00 AM\"\n```\n\n### `Date.unix(date: NSDate = NSDate()) -> Double`\n\nReturns the unix timestamp of the date passed in or the current unix timestamp\n\n```swift\nlet currentUnix = Date.unix()\n=> 1,388,552,400.0\n\nvar otherNSDate = Date()\nlet otherUnix = Date.unix(otherDate)\n=> 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=> \"Apr 10, 2015, 11:51 AM\"\n4.hours.fromNow\n=> \"Apr 11, 2015, 3:51 PM\"\n```\n\n## Dictionary Extensions ##\n\n### `merge\u003CK, V>(dictionaries: Dictionary\u003CK, V>...)`\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=> [\"foo\": \"baz\", \"spam\": \"eggs\"]\n```\n\n## Int Extensions ##\n\n### `times(callback: (Int) -> ())`\n\nInvoke a callback n times with callback that takes index\n\n```swift\n5.times { print(\"Na\") } \n=> \"NaNaNaNaNa\"\n```\n\n### `times (function: () -> ())`\n\nInvoke a callback n times\n\n```swift\n5.times { (a: Int) -> () in print(\"\\(a) \") } \n=> 0 1 2 3 4  \n```\n\n### `char -> Character`\n\nGet ASCII character from integer\n\n```swift\n65.char\n=> \"A\"\n```\n\n### `isEven`\n\nCheck if int is even\n\n```swift\n2.isEven\n=> true\n\n1.isEven\n=> false\n```\n\n### `isOdd`\n\nCheck if int is odd\n\n```swift\n3.isOdd\n=> true\n\n2.isOdd\n=> false\n```\n\n### `digits() -> [Int]`\n\nSplits the int into array of digits\n\n```swift\n4208.digits()\n=> [4, 2, 0, 8]\n```\n\n### `lcm() -> Int`\n\nLCM method return least common multiple with number passed\n\n```swift\n3.lcm(10)\n=> 30\n\n3.lcm(9)\n=> 9\n```\n\n### `gcd() -> Int`\n\nGCD method return greatest common denominator with number passed\n\n```swift\n3.gcd(10)\n=> 1\n\n3.gcd(9)\n=> 3\n```\n\n### `random() -> Int`\n\nReturns random number from 0 upto but not including value of integer\n\n```swift\n3.random()\n=> 2\n\n3.random()\n=> 1\n```\n\n### `factorial() -> Int`\n\nReturns factorial of integer\n\n```swift\n3.factorial()\n=> 6\n\n0.factorial()\n=> 1\n```\n\n### `isIn(interval) -> Bool`\n\nReturns true if i is in interval or range\n\n```swift\n5.isIn(1...10)\n=> true\n\n10.isIn(1..\u003C10)\n=> false\n```\n\n### `next() -> Int`\n\nGet the next int\n\n```swift\n10.next()\n=> 11\n```\n\n### `prev() -> Int`\n\nGet the previous int\n\n```swift\n10.prev()\n=> 9\n```\n\n### `upTo(limit: Int, callback: () -> ())`\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: () -> ())`\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=> 5\n```\n\n### `.camelCase`\n\nGet the camel case representation of the string\n\n```swift\n\"__Dollar and cent-- dollarANDCent\".camelCase\n=> \"dollarAndCentDollarAndCent\"\n```\n\n### `.kebabCase`\n\nGet the kebab case representation of the string\n\n```swift\n\"__Dollar and cent-- dollarANDCent\".kebabCase\n=> \"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=> \"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=> \"Dollar And Cent Dollar And Cent\"\n```\n\n### `=~ str: String -> 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=> true\n```\n\n### `* n: Int -> String`\n\nGet string concatenated `n` times\n\n```swift\n\"Hi Swift! \" * 3\n=> \"Hi Swift! Hi Swift! Hi Swift! \"\n```\n\n### `[i: Int] -> Character?`\n\nGet character at a subscript\n\n```swift\n\"Hello World\"[6] == \"W\"\n=> true\n\n\"Hi\"[5]\n=> nil\n```\n\n### `[str: String] -> 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=> {Some: \"Dollar\"}\n```\n\n\n### `[r: Range\u003CInt>] -> String`\n\nGet substring using subscript notation and by passing a range\n\n```swift\n\"Hello World\"[0..\u003C5] == \"Hello\" \n=> true\n```\n\n### `indexOf(char: Character) -> Int?`\n\nGet the start index of character\n\n```swift\n\"hello world\".indexOf(Character(\"o\"))!\n=> 4\n```\n\n\n### `indexOf(str: String) -> Int?`\n\nGet the start index of string\n\n```swift\n\"hello world\".indexOf(\"llo\")!\n=> 2\n\n\"hello world\".indexOf(\"illo\")\n=> nil\n```\n\n### `indexOf(pattern: String) -> Int?`\n\nGet the start index of regex pattern inside the string\n\n```swift\n\"hello world\".indexOf(\".llo\")!\n=> 1\n```\n\n### `split(delimiter: Character) -> [String]`\n\nGet an array from string split using the delimiter character\n\n```swift\n\"Hello World\".split(\" \") \n=> [\"Hello\", \"World\"]\n```\n\n### `lstrip() -> String`\n\nGet string without leading spaces\n\n```swift\nlet leadingSpace = \"  Hello\"\nleadingSpace.lstrip()\n=> \"Hello\"\n```\n\n### `rstrip() -> String`\n\nGet string without trailing spaces\n\n```swift\nlet trailingSpace = \"Hello   \"\ntrailingSpace.rstrip()\n=> \"Hello\"\n```\n\n### `strip() -> String`\n\nGet string without leading or trailing spaces\n\n```swift\nlet spaces = \"   Hello   \"\nspaces.strip()\n=> \"Hello\"\n```\n\n## Regex ##\n\n### `init`\n\nInit with regex pattern as string\n\n```swift\nRegex.init(\"^Hello.World$\") \u002F\u002F Regex that matches \"Hello World\"\n```\n\n### `matches(testStr: String) -> [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) -> Bool`\n\n```swift\nlet re = Regex.init(\"^Hello.World$\")\nre.test(\"Hello World\")\n=> true\n\nre.test(\"Str\")\n=> false\n```\n\n### `escapeStr(str: String) -> String`\n\nEscape string with regex characters\n\n```swift\nRegex.escape(\"Hello.World\")\n=> \"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=> true\n\n(1..\u003C5) == (1...5) \n=> false\n```\n\n### `eachWithIndex(callback: (T) -> ())`\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) -> () in print(\"\\(a)\") } \n=> 12345\n```\n\n### `each(callback: () -> ())`\n\nFor each index in the range invoke the callback\n\n```swift\n(1...5).each { print(\"Na\") } \n=> \"NaNaNaNaNa\"\n```\n\n# Contributing #\nIf you are interested in contributing checkout [CONTRIBUTING.md](https:\u002F\u002Fgithub.com\u002Fankurp\u002FDollar\u002Fblob\u002Fmaster\u002FCONTRIBUTING.md)\n","Dollar 是一个为 Swift 语言设计的功能性工具库，类似于 JavaScript 中的 Lo-Dash 或 Underscore.js。它提供了一系列实用的函数式编程辅助方法，而无需扩展任何内置对象。Dollar 的核心功能包括对数组、字典、对象和函数的操作支持，以及链式调用能力，这使得代码更加简洁且易于维护。适用于需要进行复杂数据处理与转换的 Swift 项目中，特别是那些希望采用函数式编程风格的应用场景。",2,"2026-06-11 03:09:25","top_language"]