Last active
March 12, 2016 09:21
-
-
Save romainmenke/8cc96c0fec72a9d29699 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
// something simple with an op at the return line | |
func foo() -> Int { | |
return 4 + 1 | |
} | |
// something verbose to get a print() of the return value | |
func foos() -> Int { | |
let value = 4 + 1 | |
print(value) | |
return value | |
} | |
// something obvious | |
extension String : CustomStringConvertible { | |
public var description : String { | |
return self | |
} | |
} | |
// something helpfull | |
extension CustomStringConvertible { | |
func debugPrintAndReturn(source: String = #file, caller: String = #function, line: Int = #line) -> Self { | |
print(source,caller,line,self) | |
return self | |
} | |
func printAndReturn() -> Self { | |
print(self) | |
return self | |
} | |
} | |
// something easy to add and remove | |
func fooz() -> Int { | |
return (4 + 1).printAndReturn() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment