Created
November 8, 2019 12:29
-
-
Save deeperunderstanding/72f59140cefa28b0f2e31d096b2d341d 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 main() { | |
val lines = Try { | |
File("./my-pets.csv").readLines().map { it.split(',') } | |
} | |
val pets : Try<List<Pet>> = lines.flatMap { Try.traverse(it, ::toPet) } | |
when (pets) { | |
is Success -> println(pets.value) | |
is Failure -> println(pets.error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment