Add “array” function for turning a sequence into an array, used after the |> operator.
This commit is contained in:
@@ -77,3 +77,8 @@ public func join<C : ExtensibleCollectionType, S : SequenceType where S.Generato
|
||||
|
||||
return join(separator, elements)
|
||||
}
|
||||
|
||||
/** Turn a sequence into an array. For use after the |> operator. */
|
||||
public func array <S : SequenceType, T where S.Generator.Element == T>(sequence: S) -> [T] {
|
||||
return Array(sequence)
|
||||
}
|
||||
|
||||
@@ -29,4 +29,11 @@ class Pipes_Tests: XCTestCase {
|
||||
XCTAssertEqual( result, 45 )
|
||||
}
|
||||
|
||||
func testTurnSequenceIntoArray () {
|
||||
let numbers = [4,1,6]
|
||||
|
||||
let result = SequenceOf(numbers) |> array
|
||||
|
||||
XCTAssertEqual( result, [4,1,6] )
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user