Ignore nil values and unwrap optionals returning the value as the wrapped type My primary concern is that this has been written as a global function.  I think it would be better if this was a function of the SignalProducer class but I am not sure that is even possible.  Is this thinking justified or is the use of global functions acceptable?

(The following code uses ReactiveCocoa 4 and is written in Swift.)

func ignoreNilValues &lt;Value,Error&gt; (producer: SignalProducer&lt;Value?,Error&gt;) -&gt; SignalProducer&lt;Value, Error&gt; {
    return producer.filter { return $0 != nil }.map { $0! }
}
There is already a function in reactiveSwift that you can use:

 .skipNil()