Skip to content

Instantly share code, notes, and snippets.

@kabutz
kabutz / virtualproxy.swift
Created October 12, 2016 15:49
Example of how easily we can build a "virtual proxy" in Swift 3.0
/*
All it takes is the "lazy" keyword in front of the var definition and the object is instantiated when it is first used. Brilliant.
*/
class MoralFibre {
init() {
print("***Creating MoralFibre***")
}
func actSociallyResponsibly() -> Int {
print("supporting local soup kitchen")