algo/swift/08_stack/BrowserDemo.swift
2018-10-13 15:37:24 +08:00

28 lines
585 B
Swift

//
// Created by Jiandan on 2018/10/12.
// Copyright (c) 2018 Jiandan. All rights reserved.
//
import Foundation
struct Page {
/// url
private var forwardArray = [String]()
/// 退 url
private var backArray = [String]()
var currentURL: String { return forwardArray.last! }
init(url: String) {
forwardArray.append(url)
}
///
mutating func goForward(url: String) {
forwardArray.append(url)
}
/// 退
mutating func goBack() {
backArray.append(forwardArray.popLast()!)
}
}