Skip to content

Instantly share code, notes, and snippets.

@el-hoshino
Last active September 4, 2015 10:34
Show Gist options
  • Save el-hoshino/175888dc5d1a3ee6d6b5 to your computer and use it in GitHub Desktop.
Save el-hoshino/175888dc5d1a3ee6d6b5 to your computer and use it in GitHub Desktop.
Swift での Int 型 switch case の落とし穴(?) ref: http://qiita.com/lovee/items/31bc2b4e66a93944c9a6
let a = 0
switch a {
case Int.min ..< 0:
print("負数")
case 0:
print("零")
case 1 ... Int.max:
print("正数")
default:
fatalError("俺はプログラマをやめるぞ!")
}
case 1 ..< Int.max, Int.max:
case ClosedInterval(1 ... Int.max):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment