Skip to content

Commit 6d1332c

Browse files
Duncan McGregordmcg
authored andcommitted
single-expressions.18 : Extract leftPart and rightPart
1 parent 353c164 commit 6d1332c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/travelator/EmailAddress.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ data class EmailAddress(
1414
require(!(atIndex < 1 || atIndex == value.length - 1)) {
1515
"EmailAddress must be two parts separated by @"
1616
}
17+
val leftPart = value.substring(0, atIndex)
18+
val rightPart = value.substring(atIndex + 1)
1719
return EmailAddress(
18-
value.substring(0, atIndex),
19-
value.substring(atIndex + 1)
20+
leftPart,
21+
rightPart
2022
)
2123
}
2224
}

0 commit comments

Comments
 (0)