Skip to content

Instantly share code, notes, and snippets.

@dimpiax
Created July 17, 2017 09:05
Show Gist options
  • Save dimpiax/a7ad78c11804ca30a06b1a856632a070 to your computer and use it in GitHub Desktop.
Save dimpiax/a7ad78c11804ca30a06b1a856632a070 to your computer and use it in GitHub Desktop.

Revisions

  1. dimpiax created this gist Jul 17, 2017.
    14 changes: 14 additions & 0 deletions Optional+.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    extension Optional where Wrapped == Bool {
    var bool: Bool {
    switch self {
    case .some(let value): return value == true
    case .none: return false
    }
    }
    }

    var foo: Bool? = true

    if foo.bool {
    print("Hello!")
    }