Skip to content

Lazy property wrapper doesn't work with closures #21

@mmdock

Description

@mmdock

Simple playground test:

class Test {
    lazy var myLazyVar: Void = {
        print("crazy")
    }()
}

print("Initialize: ")
var test = Test()
print("call first")
test.myLazyVar

will print:

Initialize: 
call first
crazy

but then you have:

class Test {
    @Lazy var myLazyVar: Void = {
        print("crazy")
    }()
}

print("Initialize: ")
var test = Test()
print("call first")
test.myLazyVar

which will print:

Initialize: 
call first

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions