hihi, does anyone knows why this works? ``` fun &...
# android
a
hihi, does anyone knows why this works?
Copy code
fun <T> Intent.getSerializableOrDefault(name: String, default: T) =
      getSerializableExtra(name) as T ?: default
my guess is that being T a non-nullable type this should crash while trying to cast, right? But apparently in my test it works:
Copy code
@Test fun `should get default`() {
        val default = ASerializableClass(2)

        assertThat(Intent().getSerializableOrDefault("a", default)).isEqualTo(default)
    }