1

Exists any difference between:

private lazy var fileManager: FileManager = { return FileManager() }()  

and

private lazy let fileManager: FileManager = FileManager() 

? Apart from being lazy (doesnt get executed until its accesed). I'm unsure if the first every time is accesed is creating a new instance.

jscs
  • 63,694
  • 13
  • 151
  • 195
Godfather
  • 4,040
  • 6
  • 43
  • 70
  • 2
    I have read both questions, i don't think it is duplicate, one deals with how often they are computed while this question deals with the syntax of defining them and the difference between two way. The question name is misleading, should be renamed. Question should be reopened, also I have an answer to this which adds useful information which makes no sense to the question marked as a duplicate. – Vlad Oct 21 '16 at 21:13
  • 1
    read here for one of the differences, seems Swift compile time can be affected by the syntax you use. We have refactored a large project to use the latter syntax to improve our compile time. https://medium.com/@RobertGummesson/regarding-swift-build-time-optimizations-fc92cdd91e31#.e3bu82h0c – Vlad Oct 21 '16 at 21:25
  • The linked duplicate answers the question in the original title as well as the last sentence of the post "I'm unsure if the first every time is accesed is creating a new instance." The title edit changed the meaning. It could be [edited by the OP further along those lines](https://gist.github.com/woolsweater/0cf7c0e6b991d83722083977f0977751), but for now, the answer to this is still found at the other. Otherwise, a new question should be asked. – jscs Oct 22 '16 at 14:37

0 Answers0