sindrenm
07/03/2017, 7:17 AMif will only work if your property is a val. The following won't compile:
class Klass {
private var prop: String? = null
fun run() {
if (prop != null) {
val firstChar = prop[0]
}
}
}
Smart cast to 'String' is impossible, because 'prop' is a mutable property that could have been changed by this timeA
prop?.let { it[0] } would work, as @aphex suggested.