fun demo(x: Any) { if (x is String) { print(x.length) // x is automatically cast to String } } fun demo2(x: Any) { x is String print(x.length) }