Created
July 25, 2015 06:33
-
-
Save haranicle/b896f4f622121ec46759 to your computer and use it in GitHub Desktop.
PatternMatchingについて #cswift #CodePiece
This file contains hidden or 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
if case let .OSX(version) = platform { | |
print(version) | |
} | |
if case let value? = optionalValue { | |
} | |
if case let (a?, b?, c?) = (optionalA, optionalB, optionalC) { | |
// optionalA,B,Cすべてがoptionalじゃないときだけ実行される | |
print(\(a)\(b)\(c)) | |
} | |
let optionals:[Int?] | |
for case let value? in optionals where value > 0 { | |
// 該当した要素だけが繰り返しの対象に | |
// whereの中でもfunctionつかえる | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment