In Kotlin, you want to create an instance of an anonymous object and assign it to a 'person' variable. This object should have two properties - a read-only ('val') property 'name' with the value 'John', and a mutable ('var') property 'age' with the value 30. You also need to print a message displaying these properties in a specific manner. Fill the blanks in the code to complete this task.
Objects and their properties
Creating an anonymous object with properties in Kotlin
Report a typo
Fill in the gaps with the relevant elements
fun () {
val person = {
name = "John"
var age = 30
}
("Name: ${person.name}, Age: ${person.age}")
} ___
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.