File tree Expand file tree Collapse file tree 4 files changed +4
-22
lines changed Expand file tree Collapse file tree 4 files changed +4
-22
lines changed Original file line number Diff line number Diff line change @@ -57,11 +57,7 @@ public struct Stack<T> {
57
57
}
58
58
59
59
public mutating func pop () -> T? {
60
- if isEmpty {
61
- return nil
62
- } else {
63
- return array.removeLast ()
64
- }
60
+ return array.popLast ()
65
61
}
66
62
67
63
public func peek () -> T? {
Original file line number Diff line number Diff line change @@ -27,11 +27,7 @@ public struct Stack<T> {
27
27
}
28
28
29
29
public mutating func pop( ) -> T ? {
30
- if isEmpty {
31
- return nil
32
- } else {
33
- return array. removeLast ( )
34
- }
30
+ return array. popLast ( )
35
31
}
36
32
37
33
public func peek( ) -> T ? {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -19,11 +19,7 @@ public struct Stack<T> {
19
19
}
20
20
21
21
public mutating func pop( ) -> T ? {
22
- if isEmpty {
23
- return nil
24
- } else {
25
- return array. removeLast ( )
26
- }
22
+ return array. popLast ( )
27
23
}
28
24
29
25
public func peek( ) -> T ? {
@@ -34,7 +30,7 @@ public struct Stack<T> {
34
30
extension Stack : SequenceType {
35
31
public func generate( ) -> AnyGenerator < T > {
36
32
var curr = self
37
- return anyGenerator {
33
+ return AnyGenerator {
38
34
_ -> T ? in
39
35
return curr. pop ( )
40
36
}
You can’t perform that action at this time.
0 commit comments