Last active
August 29, 2015 14:25
-
-
Save haranicle/d52aaa62595ad138b539 to your computer and use it in GitHub Desktop.
guardについて #cswift #CodePiece
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
guard let value != 0 else { | |
// ここでスコープを抜ける処理 | |
return | |
break | |
continue | |
fatalError() | |
} | |
// 上の条件が満たされていることを前提としたコードが書ける | |
print( 100 / value ) | |
// きもいけどこんなふうに書ける | |
guard let path = getPath() where path.hasPrefix("hoge") { | |
fatalError() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
12 行目は 行末の
{
の前にelse
を挟みます。