//: Playground - noun: a place where people can play import UIKit var str = "Hello, playground" enum Movement { case Left case Right case Top case Bottom } let aMovement = Movement.Left switch aMovement { case .Left: print("left") defa…
The singleton pattern restricts the instantiation of a class to one object. In Java, to enforce this, the best approach is to use an enum. This great idea comes straight from the book Effective Java by Joshua Bloch. If you don't have it in your libra…