fun isPasswordValid(text: String): Boolean {
if (text.length < 7) return false
// ...
}
const val MIN_PASSWORD_LENGTH = 7
fun isPasswordValid(text: String): Boolean {
if (text.length < MIN_PASSWORD_LENGTH) return false
// ...
}
// 화면에 토스트 메시지를 출력하는 확장 함수
fun Context.toast(message: String, duration: Int = Toast.LENGTH_LONG) {
Toast.makeText(this, message, duration).show()
}
fun Context.showMessage( // 메시지를 출력한다는 추상적인 이름
message: String,
duration: MessageLength = MessageLength.LONG),
) {
// ...
}
data class Id(private val id): Int