Skip to content

Instantly share code, notes, and snippets.

@chrisbrandow
Last active November 4, 2015 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbrandow/96efef7b884e157a6ecf to your computer and use it in GitHub Desktop.
Save chrisbrandow/96efef7b884e157a6ecf to your computer and use it in GitHub Desktop.
//Instead of:
func printAllKeys() {
var current: LLNode! = head
print("------------------")
while (current != nil) {
print("link item is: \(current.key)")
current = current.next
}
}
//what about:
func printAllKeys() {
print("------------------")
printAllKeys(head)
}
func printAllKeys(previous:LLNode<T>?) {
if let current = previous {
print("link item is: \(current.key)")
printAllKeys(current.next)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment