<@U5QGY080J>: Note that your `if` will only work i...
# codingconventions
s
@iex: Note that your
if
will only work if your property is a
val
. The following won't compile:
Copy code
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 time
A
prop?.let { it[0] }
would work, as @aphex suggested.