Created
March 31, 2019 17:57
-
-
Save polac24/094470308fe73d02cdb1e3ca80829b1f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// helper global function | |
func stub<T>(of v: T) -> T { | |
return nil! | |
} | |
protocol Database { | |
func addUser(name: String) -> Bool | |
} | |
class DatabaseStub: Database { | |
lazy var addUserAction = stub(of: addUser) // (String) -> Bool | |
func addUser(name: String) -> Bool { | |
return addUserAction(name) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment