Skip to content

Instantly share code, notes, and snippets.

@romainmenke
Last active March 12, 2016 09:21
Show Gist options
  • Save romainmenke/8cc96c0fec72a9d29699 to your computer and use it in GitHub Desktop.
Save romainmenke/8cc96c0fec72a9d29699 to your computer and use it in GitHub Desktop.
// 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