File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -10,20 +10,20 @@ data class EmailAddress(
10
10
companion object {
11
11
@JvmStatic
12
12
fun parse (value : String ): EmailAddress {
13
- val (leftPart, rightPart) = split(value )
13
+ val (leftPart, rightPart) = value. split(' @ ' )
14
14
return EmailAddress (
15
15
leftPart,
16
16
rightPart
17
17
)
18
18
}
19
19
20
- private fun split (value : String ): Pair <String , String > {
21
- val atIndex = value. lastIndexOf(' @ ' )
22
- require(! (atIndex < 1 || atIndex == value. length - 1 )) {
20
+ private fun String. split (divider : Char ): Pair <String , String > {
21
+ val atIndex = lastIndexOf(divider )
22
+ require(! (atIndex < 1 || atIndex == length - 1 )) {
23
23
" EmailAddress must be two parts separated by @"
24
24
}
25
- val leftPart = value. substring(0 , atIndex)
26
- val rightPart = value. substring(atIndex + 1 )
25
+ val leftPart = substring(0 , atIndex)
26
+ val rightPart = substring(atIndex + 1 )
27
27
return Pair (leftPart, rightPart)
28
28
}
29
29
}
You can’t perform that action at this time.
0 commit comments