Created
September 20, 2014 20:57
-
-
Save ericcgu/d62c461718a2799ade07 to your computer and use it in GitHub Desktop.
optional chaining
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
func findApt (aptNumber: String ) ->String? { | |
let aptNumbers = ["101", "202", "303", "404"] | |
for tempAptNumber in aptNumbers { | |
if (tempAptNumber) == aptNumber { | |
return aptNumber | |
} | |
} | |
return nil | |
} | |
func sendNoticeTo(#aptNumber:Int) { | |
} | |
if let culprit = findApt("102")?.toInt(){ | |
sendNoticeTo(aptNumber: culprit) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment