fun CampSite.isIn(countryISO: String, region: String) =
countryCode == countryISO &&
this.region.equals(region, ignoreCase = true)
Campsite
.
isIn
(...)
이 있으므로 이제
sitesInRegion
을 함수를 호출한 위치에 인라이닝
할 수 있을 것이다. 이제는 코드가 스스로 자신이 하는 일을 잘 설명해 주기 때문이다. 우리는
클라이언트를 구축할 수 있는 기초 연산을 함수 안에 감추기보다는 찾아서 공개하는 쪽을 선호
한다. 이런 방향을 따르면
region
을 선택적인 인자로 정의함으로써
isIn
의 기능을 확장할 수
있다.
예제
11.11
[
methods
-
to
-
properties
.
8
:
src
/
main
/
java
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.