Lazy readonly property in swift

<p>If readonly and private are synonyms for you in this specific case, then you can make the setter private by explicitly declaring it:</p>
<pre><code>private(set) lazy var foo : Int = { return 42 }()
</code></pre>
<p>That's a good compromise between immutability and laziness.</p>
<p>This tip was originally posted on <a href="http://stackoverflow.com/questions/26048138/Lazy%20readonly%20property%20in%20swift/26048425">Stack Overflow</a>.</p>