File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,16 @@ data class EmailAddress(
9
9
10
10
companion object {
11
11
@JvmStatic
12
- fun parse (value : String ): EmailAddress {
13
- return emailAddress(value, value.lastIndexOf(' @' ))
14
- }
12
+ fun parse (value : String ) =
13
+ emailAddress(value, value.lastIndexOf(' @' ))
15
14
16
15
private fun emailAddress (value : String , atIndex : Int ): EmailAddress =
17
- if ((atIndex < 1 || atIndex == value.length - 1 )) {
18
- throw IllegalArgumentException (
19
- " EmailAddress must be two parts separated by @ "
20
- )
21
- } else {
22
- EmailAddress (
16
+ when {
17
+ atIndex < 1 || atIndex == value.length - 1 ->
18
+ throw IllegalArgumentException (
19
+ " EmailAddress must be two parts separated by @ "
20
+ )
21
+ else -> EmailAddress (
23
22
value.substring(0 , atIndex),
24
23
value.substring(atIndex + 1 )
25
24
)
You can’t perform that action at this time.
0 commit comments