Kotlin data class, 2024-03-18

sunj - Mar 18 - - Dev Community
data class DataTicket(val companyName : String, val name : String, var date : String, var seatNumber : Int )

class Ticket(val companyName : String, val name : String, var date : String, var seatNumber : Int )

fun main(){
   val ticketA = DataTicket("koreanAir", "example", "2024-01-01", 17)
   val ticketB = Ticket("koreanAir", "example", "2024-01-01", 17)
}
Enter fullscreen mode Exit fullscreen mode

toString(), hashCode(), equal(), copy() 있음
클래스는 메모리 주소 값
데이터 클래스는 밸류 값이 나온다

참조 : Code with Joyce

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player