Last active
September 21, 2017 14:00
-
-
Save vvit/f9dff035d1845c596d8ebd7942116ec4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Singleton | |
final class Singleton { | |
static let shared = Singleton() | |
private init() { // forbid object creation | |
} | |
} | |
// Lazy | |
lazy var players = { | |
return ["A", "B"] | |
}() | |
// -OR- | |
lazy var players = self.initialPlayers() | |
func initialPlayers() -> [String] { | |
return ["A", "B"] | |
} | |
// Enumeration | |
let indexAndNum = [7, 8, 9, 10].enumerate().map { (index, element) in | |
return "\(index): \(element)" | |
} | |
// Debug literals | |
print(#file #line #column #function) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment