Skip to content

Instantly share code, notes, and snippets.

@griotspeak
Created June 18, 2015 00:54
Show Gist options
  • Save griotspeak/9595896072dcc7c5e9e2 to your computer and use it in GitHub Desktop.
Save griotspeak/9595896072dcc7c5e9e2 to your computer and use it in GitHub Desktop.
I'm sorry, dear stranger. I've done this to show you a truth.
var theCounter:Int = 0
var theString:String = ""
func doIt() -> String {
if theCounter++ % 2 == 0 {
return "wakka"
} else {
return " "
}
}
func notSoPure<T>(tuple:(T, T)) -> T {
theString.extend(doIt())
print(theString)
if theString.characters.count % 2 == 0 {
return tuple.0
} else {
return tuple.1
}
}
let theInput = (3, 4)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
notSoPure(theInput)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment