I'm confused about behavior of subscribe method in RxSwift.
This is sample code.
let observer1 = PublishSubject<String>()
let observer2 = PublishSubject<String?>()
let observable1 = Observable.just("")
let observable2 = observable1.map { $0 }
_ = observable1.subscribe(observer1) // #1. OK
_ = observable1.subscribe(observer2) // #2. Error
_ = observable2.subscribe(observer2) // #3. Error
_ = observable1.map{ $0 }.subscribe(observer2) // #4. OK
I understand that #2 and #3 get an error.
Because the observer is a nullable-string type, it is strictly different from the type that the observable holds.
But I can not understand #4.
If directly subscribe of the mapped observable, it did not get an error.
As shown in #3, the return value of the mapped observable1 was Observable.
I look forward to reply.