Skip to content

Instantly share code, notes, and snippets.

@tifoaudii
Created July 30, 2019 06:17
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 tifoaudii/546cfffe004308f977463e9ad0e3fc39 to your computer and use it in GitHub Desktop.
Save tifoaudii/546cfffe004308f977463e9ad0e3fc39 to your computer and use it in GitHub Desktop.
Create a class represent a Node object that consist of value and next reference
class Node<Value> {
var value: Value
var next: Node<Value>?
init(value: Value, next: Node<Value>? = nil ) {
self.value = value
self.next = next
}
}
extension Node: CustomStringConvertible {
var description: String {
guard let next = next else {
return "\(value)"
}
return "\(value) ->" + "\(next)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment