Skip to content

Commit 0723f38

Browse files
author
Ahmed Onawale
committed
update readme to include refactored code
1 parent cc17adc commit 0723f38

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Linked List/README.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ How about reversing a list, so that the head becomes the tail and vice versa? Th
449449
```swift
450450
public func reverse() {
451451
var node = head
452-
while node != nil {
453-
swap(&node!.next, &node!.previous)
454-
head = node
455-
node = node!.previous
452+
while let currentNode = node {
453+
swap(&currentNode.next, &currentNode.previous)
454+
head = currentNode
455+
node = currentNode.previous
456456
}
457457
}
458458
```

0 commit comments

Comments
 (0)