Skip to content

Instantly share code, notes, and snippets.

@niwatako
Created July 20, 2016 09:02
Show Gist options
  • Save niwatako/7a413a216cc7894c20954c633d16a53c to your computer and use it in GitHub Desktop.
Save niwatako/7a413a216cc7894c20954c633d16a53c to your computer and use it in GitHub Desktop.
string2 が nil の時に print("load") が実行されてほしいのです https://twitter.com/rizumita/status/755687567933120513 #CodePiece
let string1 = "" // これが isEmpty なら
let string2: String? = nil // nil の時でも
if let s = string2 where s == "string" || string1.isEmpty {
print("load") // 実行されたい
}
// こんな書き方はできないけどイメージはこれ if (let where ) || ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment