Skip to content

Commit 25acd20

Browse files
committed
Use if-case-let
1 parent da31fb8 commit 25acd20

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

ReactiveTask/Task.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,10 @@ public enum TaskEvent<T>: TaskEventType {
262262

263263
/// The resulting value, if the event is `Success`.
264264
public var value: T? {
265-
switch self {
266-
case .Launch, .StandardOutput, .StandardError:
267-
return nil
268-
269-
case let .Success(value):
265+
if case let .Success(value) = self {
270266
return value
271267
}
268+
return nil
272269
}
273270

274271
/// Maps over the value embedded in a `Success` event.

ReactiveTaskTests/TaskSpec.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ class TaskSpec: QuickSpec {
3535
it("should launch a task that writes to stdout") {
3636
let result = launchTask(Task("/bin/echo", arguments: [ "foobar" ]))
3737
.reduce(NSMutableData()) { aggregated, event in
38-
switch event {
39-
case let .StandardOutput(data):
38+
if case let .StandardOutput(data) = event {
4039
aggregated.appendData(data)
41-
42-
default:
43-
break
4440
}
4541

4642
return aggregated
@@ -56,12 +52,8 @@ class TaskSpec: QuickSpec {
5652
it("should launch a task that writes to stderr") {
5753
let result = launchTask(Task("/usr/bin/stat", arguments: [ "not-a-real-file" ]))
5854
.reduce(NSMutableData()) { aggregated, event in
59-
switch event {
60-
case let .StandardError(data):
55+
if case let .StandardError(data) = event {
6156
aggregated.appendData(data)
62-
63-
default:
64-
break
6557
}
6658

6759
return aggregated

0 commit comments

Comments
 (0)