Hi! Why is this OK ``` rebookingList.filter { ...
# announcements
c
Hi! Why is this OK
Copy code
rebookingList.filter {
        val data = it.data
        when (data) {
            is AccountFeedItem<*> -> {
                data.data is FeedItemTreatment
            }
            else -> false
        }
    }
But this isn't?
Copy code
rebookingList.filter {
        when (it.data) {
            is AccountFeedItem<*> -> {
                it.data.data is FeedItemTreatment
            }
            else -> false
        }
    }
d
The compiler cannot be sure that
it.data
is not subject to change, so it will not smart-cast
👍 3
c
Ahh of course! Thank you 🙂
i
@Can Orhan to be specific in 2nd example other thread may change
data
BTW I think that in Kotlin 1.3 you will be able to do this
when (val data = it.data)