You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Linked List/README.markdown
+3-3
Original file line number
Diff line number
Diff line change
@@ -109,7 +109,7 @@ Let's also add a property that gives you the last node in the list. This is wher
109
109
```swift
110
110
publicvar last: Node? {
111
111
ifvar node = head {
112
-
whilecaselet next?= node.next {
112
+
whilelet next = node.next {
113
113
node = next
114
114
}
115
115
return node
@@ -121,7 +121,7 @@ Let's also add a property that gives you the last node in the list. This is wher
121
121
122
122
If you're new to Swift, you've probably seen `if let` but maybe not `if var`. It does the same thing -- it unwraps the `head` optional and puts the result in a new local variable named `node`. The difference is that `node` is not a constant but an actual variable, so we can change it inside the loop.
123
123
124
-
The loop also does some Swift magic. The `while case let next? = node.next` bit keeps looping until `node.next` is nil. You could have written this as follows:
124
+
The loop also does some Swift magic. The `while let next = node.next` bit keeps looping until `node.next` is nil. You could have written this as follows:
125
125
126
126
```swift
127
127
var node: Node?= head
@@ -198,7 +198,7 @@ Let's add a method to count how many nodes are in the list. This will look very
0 commit comments