Reputation: 1664
I'm trying to achieve the following:
let reachedTopMostMessage = PublishSubject<Int?>()
reachedTopMostMessage.startWith(nil).subscribeNext { (_) in
//
}
But the compiler complains with this error:
'Int?' (aka 'Optional') is not convertible to '(Int?...)' (aka '(Optional...)')
What is wrong with this?
Upvotes: 1
Views: 725
Reputation: 7729
Use Optional<Int>()
to create a nil
Int?
, not just nil
.
let reachedTopMostMessage = PublishSubject<Int?>()
reachedTopMostMessage.startWith(Optional<Int>()).subscribeNext { (_) in
//
}
Upvotes: 2