Created
September 26, 2016 11:13
-
-
Save tikidunpon/020a9dd84ae79da511ac64eccd677512 to your computer and use it in GitHub Desktop.
data class便利だよねー #kotlin_power, #CodePiece #kotlin
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 name: String, val id: Int) | |
fun getUser(): User { | |
return User("Alex", 1) | |
} | |
fun main(args: Array<String>) { | |
val user = getUser() | |
println("name = ${user.name}, id = ${user.id}") | |
// or | |
val (name, id) = getUser() | |
println("name = $name, id = $id") | |
// or | |
println("name = ${getUser().component1()}, id = ${getUser().component2()}") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment