Does the Kotlin compiler translate \"Hello, $name!\"
using something like
java.lang.String.format(\"Hello, %s!\", name)
or is
Regarding your 2nd question:
If you need caching for fullName
, you may and should do it explicitly:
class Client {
val firstName: String
val lastName: String
val fullName = "$firstName $lastName"
}
This code is equivalent to your snipped except that the underlying getter getFullName()
now uses a final private field with the result of concatenation.