Pass values into a constructor when creating an object.

Constructors

Constructors.kt
class Rectangle(val width: Int, val height: Int)

fun main() {
    val width = 
    val height = 3
    val rectangle = Rectangle(width, height)
    val area = rectangle.width * rectangle.height

    println("width=$width")
    println("area=$area")
}
class Rectangle(val width: Int, val height: Int)

fun main() {
    val width = 
    val height = 3
    val rectangle = Rectangle(width, height)
    val area = rectangle.width * rectangle.height

    println("width=$width")
    println("area=$area")
}
class Rectangle(val width: Int, val height: Int)

fun main() {
    val width = 
    val height = 3
    val rectangle = Rectangle(width, height)
    val area = rectangle.width * rectangle.height

    println("width=$width")
    println("area=$area")
}
constructor A constructor receives the values needed to build an object.