Created
November 8, 2019 16:49
-
-
Save deeperunderstanding/f6775d41051e54f1a1a6ccf1454a836c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun toPet(values: List<String>) = Try.sequential { | |
val name = values[0] | |
val (age) = Try { values[1].trim().toInt() } | |
val (type) = PetType.lookup(values[2].trim()) | |
Pet(name, age, type) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment