I
Size: a a a
I
I
inline class DP(val i: Int) {
override fun toString(): String {
return "$i dp"
}
}
operator fun DP.plus(other: DP) = DP(i + other.i)
val Int.dp; get() = DP(this)
data class Rectangle(
val topLeftX: DP,
val topLeftY: DP,
val bottomRightX: DP,
val bottomRightY: DP,
) {
fun resize(h: DP, w: DP): Rectangle {
println("New size: $w, $h")
return Rectangle(
topLeftX = topLeftX,
topLeftY = topLeftY,
bottomRightX = topLeftX + h,
bottomRightY = topLeftY + w
)
}
}
fun main() {
println(Rectangle(0.dp, 0.dp, 10.dp, 10.dp).resize(5.dp, 10.dp))
}
BP
inline class DP(val i: Int) {
override fun toString(): String {
return "$i dp"
}
}
operator fun DP.plus(other: DP) = DP(i + other.i)
val Int.dp; get() = DP(this)
data class Rectangle(
val topLeftX: DP,
val topLeftY: DP,
val bottomRightX: DP,
val bottomRightY: DP,
) {
fun resize(h: DP, w: DP): Rectangle {
println("New size: $w, $h")
return Rectangle(
topLeftX = topLeftX,
topLeftY = topLeftY,
bottomRightX = topLeftX + h,
bottomRightY = topLeftY + w
)
}
}
fun main() {
println(Rectangle(0.dp, 0.dp, 10.dp, 10.dp).resize(5.dp, 10.dp))
}
AM
BP
AM
QH
inline class DP(val i: Int) {
override fun toString(): String {
return "$i dp"
}
}
operator fun DP.plus(other: DP) = DP(i + other.i)
val Int.dp; get() = DP(this)
data class Rectangle(
val topLeftX: DP,
val topLeftY: DP,
val bottomRightX: DP,
val bottomRightY: DP,
) {
fun resize(h: DP, w: DP): Rectangle {
println("New size: $w, $h")
return Rectangle(
topLeftX = topLeftX,
topLeftY = topLeftY,
bottomRightX = topLeftX + h,
bottomRightY = topLeftY + w
)
}
}
fun main() {
println(Rectangle(0.dp, 0.dp, 10.dp, 10.dp).resize(5.dp, 10.dp))
}
BP
BP
I
BP
BP
I
BP
QH
BP
QH
BP
QH
BP