-
-
Save ehsansouri23/bd57faa84fed1df9f410f569d8eae287 to your computer and use it in GitHub Desktop.
using With Kotlin function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class User( | |
val firstName:String, | |
val lastName:String, | |
val address:Address | |
) | |
// using `with` function | |
val user = User() | |
with(user) { | |
println(firstName) | |
println(lastName) | |
println(address) | |
} | |
// not using `with` function | |
val user = User() | |
println(user.firstName) | |
println(user.lastName) | |
println(user.address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment