JavaScript (Lo-Dash, Underscore) & Ruby inspired set of Swift extensions for standard types and classes.
Examples in Examples/Array.md
Name |
Signature |
first |
first () -> T? |
last |
last () -> T? |
get |
get (index: Int) -> T? |
remove |
remove <U: Equatable> (element: U) |
take |
take (n: Int) -> Array<T> |
contains |
contains <T: Equatable> (item: T) -> Bool |
difference |
difference <T: Equatable> (values: Array<T>...) -> Array<T> |
intersection |
func intersection <U: Equatable> (values: Array<U>...) -> Array<T> |
union |
func union <U: Equatable> (values: Array<U>...) -> Array<T> |
unique |
unique <T: Equatable> () -> Array<T> |
indexOf |
func indexOf <T: Equatable> (item: T) -> Int |
zip |
zip (arrays: Array<Any>...) -> Array<Array<Any?>> |
shuffle |
shuffle () |
shuffled |
shuffled () -> Array<T> |
sample (random) |
sample (size n: Int = 1) -> Array<T> |
max |
max <T: Comparable> () -> T |
min |
min <T: Comparable> () -> T |
each |
each (call: (T) -> ())
each (call: (Int, T) -> ()) |
any |
any (call: (T) -> Bool) -> Bool |
all |
all (call: (T) -> Bool) -> Bool |
reject |
reject (exclude: (T -> Bool)) -> Array<T> |
pop |
pop() -> T |
push |
push(newElement: T) |
shift |
shift() -> T |
unshift |
unshift(newElement: T) |
groupBy |
groupBy <U> (groupingFunction group: (T) -> (U)) -> Dictionary<U, Array<T>> |
reduceRight |
reduceRight <U>(initial: U, combine: (U, Element) -> U) -> U |
implode |
implode <C: ExtensibleCollection> (separator: C) -> C? |
Name |
Signatures |
range |
range <U: ForwardIndex> (range: Range<U>) -> Array<U> |
Name |
Signature |
Function |
- |
<T: Equatable> (first: Array<T>, second: Array<T>) -> Array<T> |
Difference |
& |
<T: Equatable> (first: Array<T>, second: Array<T>) -> Array<T> |
Intersection |
| |
<T: Equatable> (first: Array<T>, second: Array<T>) -> Array<T> |
Union |
[x..y]
[x...y] |
subscript(range: Range<Int>) -> Array<T> |
Returns the sub-array from index x to index y |
Examples in Examples/Int.md
Name |
Signatures |
times |
times <T> (call: (Int) -> T)
times <T> (call: () -> T)
times (call: () -> ()) |
after |
after <T> (call: () -> T) -> (() -> T?) |
isEven |
isEven () -> Bool |
isOdd |
idOdd () -> Bool |
upTo |
upTo (limit: Int, call: (Int) -> ()) |
downTo |
downTo (limit: Int, call: (Int) -> ()) |
Name |
Signatures |
random |
random(min: Int = 0, max: Int) -> Int |
Name |
Signature |
abs |
abs () -> Float |
Name |
Signatures |
Usage |
random |
random(min: Float = 0, max: Float) -> Float |
Float.random(min: 1, max: 1000) |
Examples in Examples/String.md
Name |
Signature |
length |
length () -> Int |
explode |
explode (separator: Character) -> String[] |
Name |
Signature |
random |
func random (var length len: Int = 0, charset: String = "...") -> String |
Name |
Signature |
[x] |
subscript(index: Int) -> String? |
[x..y]
[x...y] |
subscript(range: Range<Int>) -> String |
S * n |
* (first: String, second: Int) -> String |
Name |
Signatures |
Usage |
times |
times (call: (T) -> ())
times (call: () -> ()) |
(2..4).times({ (index: Int) in println(index) })
(2..4).times({ println("Hi") }) |
each |
each (call: (T) -> ()) |
(2..4).each({ (index: Int) in println(index) }) |
Name |
Signature |
Function |
= |
== <U: ForwardIndex> (first: Range<U>, second: Range<U>) -> Bool |
Compares 2 ranges |
Examples in Examples/Dictionary.md
Name |
Signatures |
has |
has (key: KeyType) -> Bool |
isEmpty |
isEmpty () -> Bool |
map |
map(mapFunction map: (KeyType, ValueType) -> (KeyType, ValueType)) -> Dictionary<KeyType, ValueType> |
mapValues |
mapValues(mapFunction map: (KeyType, ValueType) -> (ValueType)) -> Dictionary<KeyType, ValueType> |
each |
each(eachFunction each: (KeyType, ValueType) -> ()) |
filter |
filter(testFunction test: (KeyType, ValueType) -> Bool) -> Dictionary<KeyType, ValueType> |
merge |
merge (dictionaries: Dictionary<KeyType, ValueType>...) -> Dictionary<KeyType, ValueType> |
shift |
shift () -> (KeyType, ValueType) |
groupBy |
groupBy <T> (groupingFunction group: (KeyType, ValueType) -> (T)) -> Dictionary<T, Array<ValueType>> |
any |
any (test: (KeyType, ValueType) -> (Bool)) -> Bool |
all |
all (test: (KeyType, ValueType) -> (Bool)) -> Bool |
reduce |
reduce <U> (initial: U, combine: (U, Element) -> U) -> U |
- Compile as library as soon as XCode 6 stops crashing.
- Benchmark
- ...