Skip to Content
자바에서 코틀린으로
book

자바에서 코틀린으로

by 덩컨 맥그레거, 냇 프라이스, 오현석
November 2022
Beginner to intermediate
544 pages
12h 39m
Korean
Hanbit Media, Inc.
Content preview from 자바에서 코틀린으로
218
자바에서 코틀린으로
객체의 모든 프로퍼티를 사용한 암호학적 해시
1
는 어떨까? 이런 해시는 계산 (불변 객체의 경
우)이다. 하지만 계산 비용이 많이 들기 때문에
hash
라는 프로퍼티가 아니라
hash
()
라는 함
수여야 한다. 저자들은 이름에 메서드의 계산 비용에 대한 힌트를 덧붙이기를 원한다.
data class PersonWithProperties(
val givenName: String,
val familyName: String,
val dateOfBirth: LocalDate
) {
fun computeHash(): ByteArray =
someSlowHashOf(givenName, familyName, dateOfBirth.toString())
}
계산을 미리해서 필드에 저장하면 이 값을 프로퍼티로 만들 수 있다.
data class PersonWithProperties(
val givenName: String,
val familyName: String,
val dateOfBirth: LocalDate
) {
val hash: ByteArray =
someSlowHashOf(givenName, familyName, dateOfBirth.toString())
}
이 구현은
hash
접근 여부와 관계없이 모든 인스턴스 생성이
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

고성능 파이썬(2판)

고성능 파이썬(2판)

오현석, 미샤 고렐릭, 이안 오스발트
러닝 타입스크립트

러닝 타입스크립트

조시 골드버그
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791169210447