Skip to content

Optional variables as lazy? #2

@eonist

Description

@eonist

Could we make the instance variable non-optional? Example:

lazy var someSize:CGSize = {
   let x:CGFloat = 0
   let y:CGFloat = 0
   let size = CGSize(x,y,0,0)
   return size
}()

//Now we can use someSize with out force unwrap 👌
//What happens is that the var isn't created until something asks for it.
print(someSize.x)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions