Using the default Swift with Xcode 7.3.1.

It appears that you cannot use the implicit memberwise initializer with a 
struct that has “let” properties with default values.

This works perfectly:

    struct CF {
        let prop: Int
    }
    let cf = CF(prop: 1)

But give the property a default value:

    struct CF {
        let prop: Int = 0
    }
    let cf = CF(prop: 1)

And now the compiler complains:

    error: argument passed to call that takes no arguments
    let cf = CF(prop: 1)
               ~~~~~~~^~

I don’t believe that the Apple _The Swift Programming Language_ mentions this 
restriction.

        Neil Faiman
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to