private fun String.splitAroundLast(divider: Char): Pair<String, String> =
lastIndexOf(divider).let { index ->
require(index >= 1 && index != length - 1) {
“string must be two non-empty parts separated by $divider”
}
substring(0, index) to substring(index + 1)
}
splitAroundLast
가 표준 라이브러리의
String
.
split
과 충돌하지 않는 더 좋은 이름처럼
보인다. 그리고 이 이름은 문자열을 나누는 구분자의 양쪽이 모두 비어있지 않아야 한다는 사
실을 알려 준다.
around
는, 이런 단어를 식별자에 ...
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.