KrakenDev


Here's to the crazy ones. The misfits. The troublemakers. The Swifters.

Viewing entries tagged
virtue of let

The Right Way To Write a Singleton

Due to the nature of a beta language, Swift didn't have all the right things it needed when it first started out. For instance, Singletons, over the course of the development of Swift from 1.0 to 1.2, gained several different implementations. Unfortunately, the proper way to write a singleton hasn't been propagated amongst the community yet due to the lack of documentation outlining how to write a singleton. What does "by virtue of let" mean anyways? How do we know our current implementation of a one line singleton satisfies the rules of being a singleton?