while循环的语法含义是什么

时间:2019-04-29 06:45:15

标签: swift

我在hackingwithswift博客上遇到了这段代码。那么上面这个listloop的意义是什么(这种语法意味着什么)

indirect enum LinkedListItem<T> {
    case endPoint(value: T)
    case linkNode(value: T, next: LinkedListItem)
}

let third = LinkedListItem.endPoint(value: "Third")
let second = LinkedListItem.linkNode(value: "Second", next: third)
let first = LinkedListItem.linkNode(value: "First", next: second)

var currentNode = first

listLoop: while true {
    switch currentNode {
    case .endPoint(let value):
        print(value)
        break listLoop
    case .linkNode(let value, let next):
        print(value)
        currentNode = next
    }
}

0 个答案:

没有答案