Skip to content

Commit

Permalink
Adds delegation to maps example
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperancinha committed Nov 9, 2023
1 parent eb6c3d3 commit 4dce686
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ class Account(
val number: String
) : Person by person, Card by card


class User(details: Map<String, String>) {
val name by details
val address by details

override fun toString(): String = "User name is $name and address is $address"
}

class Delegates {
companion object {
@JvmStatic
Expand All @@ -48,6 +56,9 @@ class Delegates {
println(account.address)
println(account.cardNumber)
println(account.expiryDate)

val user = User(mapOf("name" to "Priscilla", "address" to "Silicon Valley"))
println(user)
}
}
}

0 comments on commit 4dce686

Please sign in to comment.