You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
544 B

5 years ago
  1. //
  2. // unwrap+SharedSequence.swift
  3. // RxSwiftExt
  4. //
  5. // Created by Hugo Saynac on 05/10/2018.
  6. // Copyright © 2018 RxSwift Community. All rights reserved.
  7. //
  8. import RxCocoa
  9. extension SharedSequence {
  10. /**
  11. Takes a SharedSequence of optional elements and returns a SharedSequence of non-optional elements, filtering out any nil values.
  12. - returns: A SharedSequence of non-optional elements
  13. */
  14. public func unwrap<T>() -> SharedSequence<S, T> where E == T? {
  15. return self.filter { $0 != nil }.map { $0! }
  16. }
  17. }