YogenGhodke
8/31/2019 - 7:00 PM

Data Classes

Used for Declaring Classes that hold mostly Data Members.

data class Fish(val texture: String)
{
    val x = 3
}


fun main()
{
    val f = Fish("Slippery")
    print(f)        // Prints values of Members rather than Address of the object


    val (touch) = f         // Assigning data members of the class to the variable
    println(touch)
}