Skip to content

Commit 2b20def

Browse files
authored
Merge pull request kodecocodes#321 from raywenderlich/Queue-Naming-Fix
Modified the peek property name to front
2 parents e61e743 + 7050669 commit 2b20def

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

Queue/Queue.playground/Contents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public struct Queue<T> {
3434
}
3535
}
3636

37-
public var peek: T? {
37+
public var front: T? {
3838
return array.first
3939
}
4040
}
@@ -56,7 +56,7 @@ queueOfNames.dequeue()
5656

5757
// Return the first element in the queue.
5858
// Returns "Lisa" since "Carl" was dequeued on the previous line.
59-
queueOfNames.peek
59+
queueOfNames.front
6060

6161
// Check to see if the queue is empty.
6262
// Returns "false" since the queue still has elements in it.

Queue/Queue.playground/timeline.xctimeline

Lines changed: 0 additions & 6 deletions
This file was deleted.

Queue/README.markdown

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public struct Queue<T> {
6868
}
6969
}
7070

71-
public func peek() -> T? {
71+
public var front: T? {
7272
return array.first
7373
}
7474
}
@@ -166,12 +166,8 @@ public struct Queue<T> {
166166
return element
167167
}
168168

169-
public func peek() -> T? {
170-
if isEmpty {
171-
return nil
172-
} else {
173-
return array[head]
174-
}
169+
public var front: T? {
170+
return array.first
175171
}
176172
}
177173
```

0 commit comments

Comments
 (0)