Let's say you have an instance of a data class with some settings: fontFamily, text, and textSize. Use apply and also to change the value of text based on data from standard input and print the updated instance of the class.
Scope functions: apply and also
Text field parameters
Report a typo
Sample Input 1:
ButtonSample Output 1:
Old settings: TextField(text=Hello!, textSize=12, fontFamily=Roboto)
New settings: TextField(text=Button, textSize=12, fontFamily=Roboto)Write a program in Kotlin
data class TextField(
var text: String = "Hello!",
var textSize: Int = 12,
var fontFamily: String = "Roboto"
)
fun main() {
val textField = TextField()
textField // Write your code here
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.