속 통과할 수 있다는 사실에 놀랄 수도 있다. 하지만 이 경우 테스트가 성공해야만 한다고 추론
할 수 있다.
featuredDestinations
::
findCloseTo
에 연결된 함수는 여전히 목 인터페이스
의 메서드를 호출하기 때문이다. 하지만 실제로 테스트를 실행해 보면 이런 추론이 틀렸음이
판명되는 경우도 자주 있으므로 섣부른 판단은 금물이다.
하지만 모든 걸 같은 방식으로 처리하는 쪽을 선호하므로,
distanceCalculator
에 대해서도
같은 변경을 적용하자. 이번에는 뭐가 됐든 한꺼번에 해버리자.
예제
16.13
[
interfaces
-
to
-
funs
.
7
:
src
/
main
/
java
/
travelator
/
recommendations
/
Recommendations
.
kt
]
class Recommendations(
private val destinationFinder: (Location) -> List<FeaturedDestination>,
private val distanceInMetersBetween: (Location, Location) -> Int
) {
...
fun recommendationsFor(
location: Location ...
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.