XMLCoder icon indicating copy to clipboard operation
XMLCoder copied to clipboard

Property wrappers error

Open Vinestro89 opened this issue 3 years ago • 1 comments

Hi !

Following the example given in the documentation:

struct Book: Codable {
    @Element var id: Int
}

I tried to create an instance of a Book:

let book = Book(id: 42)

But I get the following error:

Cannot convert value of type 'Int' to expected argument type 'Element<Int>'

To make it work I have to do:

let book = Book(id: Element(42))

Is there something I'm doing wrong ? Thank you 😊

Vinestro89 avatar Feb 27 '23 09:02 Vinestro89

No, his is correct as it stands. But I'll keep the issue open as I think we can fix it in the signature.

Joannis avatar Feb 27 '23 09:02 Joannis