Last active
May 10, 2019 16:13
-
-
Save arkivanov/e1ad0b6f1a63957ed18312ec788f6cb0 to your computer and use it in GitHub Desktop.
Reaktive null-safety exmaples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
observableOf<String>(null) // Compilation error | |
// 2 | |
val o1: Observable<String?> = observableOf(null) | |
val o2: Observable<String> = o1 // Compilation error, types do not match | |
// 3 | |
val o1: Observable<String?> = observableOf(null) | |
val o2: Observable<String> = o1.notNull() // No error, null values filtered out | |
// 4 | |
val o1: Observable<String> = observableOf(“Hello”) | |
val o2: Observable<String?> = o1 // No error | |
// 5 | |
val o1: Observable<String?> = observableOf(null) | |
val o2: Observable<String> = observableOf(“Hello”) | |
val o3: Observable<String?> = merge(o1, o2) // No error | |
val o4: Observable<String> = merge(o1, o2) // Compilation error, types do not match |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment