Skip to content

Commit bd7e4b1

Browse files
committed
Fixed node(atIndex:) method to be the same in LinkedList.swift file.
1 parent 71ae5a3 commit bd7e4b1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Linked List/LinkedList.playground/Contents.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public final class LinkedList<T> {
7272
/// - Returns: Optional LinkedListNode
7373
public func node(atIndex index: Int) -> Node {
7474
assert(head != nil, "List is empty")
75+
assert(index >= 0, "index must be greater than 0")
76+
7577
if index == 0 {
7678
return head!
7779
} else {

0 commit comments

Comments
 (0)