On Wed, Mar 8, 2017 at 5:09 AM, Haravikk via swift-evolution <
swift-evolution@swift.org> wrote:

> willSet and didSet have their own distinct scope; they execute
> independently, however a switch statement is effectively a single scope
> because of the ability to use fallthrough to visit later cases.
>

A switch statement has a separate scope for every case, including default.
Example:

switch Int() {
case 0:
    let m = "zero"
    fallthrough
default:
    Swift.print(m)
}


Result:

Playground execution failed: error: MyPlayground.playground:2:17: error:
use of unresolved identifier 'm'
    Swift.print(m)
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to