data class Ticket(val companyName : String, val name : String, var dat : String, var seat : Int)
fun main() {
val ticketA = Ticket("koreaAir", "nana", "2022-07-04",06)
}
toString(), hashCode(), equals(), copy() 컴파일러가 자동으로 생성해 준다.
class Book private constructor (val id:Int, val name:String){
companion object BookFactory : IdPro{
override fun getId() : Int {
return 33
}
val myBook = "New name"
fun create() = Book(getId(),myBook)
}
}
interface IdPro{
fun getId() : Int
}
fun main() {
var book = Book.create()
println("${book.id} ${book.name}")
}