From 991da5fd392140461fe43d4e3a2afb4b58bb00cf Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Thu, 23 Oct 2014 00:14:10 +0200 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9Carray=E2=80=9D=20function=20for?= =?UTF-8?q?=20turning=20a=20sequence=20into=20an=20array,=20used=20after?= =?UTF-8?q?=20the=20|>=20operator.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SwiftShell/Pipes.swift | 5 +++++ SwiftShellTests/Pipes_Tests.swift | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/SwiftShell/Pipes.swift b/SwiftShell/Pipes.swift index 6f3a7a1..092a1f5 100644 --- a/SwiftShell/Pipes.swift +++ b/SwiftShell/Pipes.swift @@ -77,3 +77,8 @@ public func join operator. */ +public func array (sequence: S) -> [T] { + return Array(sequence) +} diff --git a/SwiftShellTests/Pipes_Tests.swift b/SwiftShellTests/Pipes_Tests.swift index ad20c2e..4c919c1 100644 --- a/SwiftShellTests/Pipes_Tests.swift +++ b/SwiftShellTests/Pipes_Tests.swift @@ -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] ) + } }