Created
June 18, 2015 00:54
-
-
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.
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
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