Created
October 13, 2015 02:16
-
-
Save crazytonyli/c3554df7e5f039b9ef78 to your computer and use it in GitHub Desktop.
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
| extension Optional where Wrapped: IntegerType { | |
| func nilOrZero() -> Bool { | |
| switch self { | |
| case .None: return true | |
| case .Some(let value): return value == 0 | |
| } | |
| } | |
| } | |
| var arr: [Int]? | |
| arr?.count == 0 // false | |
| (arr?.count).nilOrZero() // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment