Lazy var on @Observable class

I was under the impression that private vars weren't synthesised in @Observable classes.
When I tried to use a lazy var, I get the error 'lazy' cannot be used on a computed property, which I infer as meaning the var is the synthesised version.

@Observable class MyClass {

    private lazy var something = ""
}

Am I missing something here?
Thanks

private vars are synthesized; since they can compose to public accessors. lazy cannot be transformed due to not being able to synthesize that effect (hence the error). If you need a lazy property you can add the @ObservationIgnored macro on it and the observation system will ignore synthesis for that property.

2 Likes