Complete the code to declare a map-backed delegated property for 'name'.
val user = mapOf("name" to "Alice", "age" to 30) val name: String by [1]
The property 'name' is delegated to the map 'user'. This means 'name' will get its value from the map's 'name' key.
Complete the code to access the 'age' property delegated to the map.
val user = mapOf("name" to "Bob", "age" to 25) val age: Int by [1] println(age)
The 'age' property is delegated to the 'user' map, so it retrieves the value associated with the 'age' key.
Fix the error in the code to correctly delegate 'email' property to the map.
val user = mapOf("email" to "test@example.com") val email: String by [1] println(email)
The property 'email' must delegate to the existing 'user' map to access the stored value.
Fill both blanks to create a map-backed delegated property 'city' and print its value.
val data = mapOf("city" to "Paris", "country" to "France") val city: String by [1] println([2])
The property 'city' delegates to the map 'data'. To print the value, use the property name 'city'.
Fill all three blanks to create map-backed delegated properties 'firstName' and 'lastName', then print full name.
val personData = mapOf("firstName" to "John", "lastName" to "Doe") val firstName: String by [1] val lastName: String by [2] println("Full name: $[3] $lastName")
Both 'firstName' and 'lastName' delegate to the 'personData' map. To print the full name, use the 'firstName' property followed by 'lastName'.