Using ReactiveSwift, I've used the following code:
let alertMessageProperty = MutableProperty<String?>(nil)
...
.on(failed: { self.alertMessageProperty.value = $0.localizedDescription })
...
which means:
self.alertMessageProperty.value
is of typeString?
- in
.on(failed:)
,failed
is of type((Error) -> Void)?
so$0
is of type Error and$0.localizedDescription
is of typeString
. - in a simple Playground, assigning a
String
to aString?
variable works fine, as expected.
It does not compile and I get this error:
'String' is not convertible to 'String?'
I think String
is SO convertible to String?
. What's going on here?
Versions: Swift 3.2 - ReactiveSwift 2.0.1