Skip to content

Instantly share code, notes, and snippets.

@yutailang0119
Created October 14, 2017 03:21
Show Gist options
  • Save yutailang0119/f80171721a94b7aedbb19175a383587c to your computer and use it in GitHub Desktop.
Save yutailang0119/f80171721a94b7aedbb19175a383587c to your computer and use it in GitHub Desktop.
let values: [Int?] = [1, 2, nil, 4, 5]
for value in values where value != nil {
print(value!, type(of: value!))
}
for case let value? in values {
print(value, type(of: value))
}
/**
1 Int
2 Int
4 Int
5 Int
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment