Skip to content

Instantly share code, notes, and snippets.

@masukomi
Created January 24, 2016 19:27
Show Gist options
  • Save masukomi/10a2acd7fc43c25c34ad to your computer and use it in GitHub Desktop.
Save masukomi/10a2acd7fc43c25c34ad to your computer and use it in GitHub Desktop.
extension SomeClass {
func getLowOrHighNum(numA: Int?, numB: Int?, lowOrHigh: String) -> Int? {
let numArray = [numA, numB].filter({ $0 != nil});
return numArray.sort(
lowOrHigh == "low" ? { $0! < $1} : {$0! > $1 }
).first!!;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment