Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Created January 2, 2021 14:01
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 le0nidas/096c9cc9065a226768072eece1df50c7 to your computer and use it in GitHub Desktop.
Save le0nidas/096c9cc9065a226768072eece1df50c7 to your computer and use it in GitHub Desktop.
interface History {
fun push(url: URL)
fun pop(): URL
fun peek(): URL
}
class Browser(
private val history: History
) {
var activeURL: URL? = null
private set
fun visit(url: URL) {
activeURL = if (url == URL("http://default"))
history.peek() else
url
history.push(activeURL!!)
}
fun back() {
history.pop()
activeURL = history.peek()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment