74 단어
1 분
Kotlin 커스텀 접근자
2025-04-07
2025-04-07

커스텀 접근자#

class Rectangle(val height: Int, val width: Int) {
	val isSquare: Boolean
		get() {
			height == width
		}
}

코틀린에서는 식으로 표현할 수 있다. 따라서 아래와 같은 코드로 작성할 수도 있다.

class Rectangle(val height: Int, val width: Int) {
	val isSquare: Boolean
		get() = height == width
}
Kotlin 커스텀 접근자
https://realits.me/posts/kotlin-custom/
저자
realitsyourman
게시일
2025-04-07
라이선스
CC BY-NC-SA 4.0