Skip to content

Instantly share code, notes, and snippets.

@deeperunderstanding
Created November 8, 2019 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deeperunderstanding/72f59140cefa28b0f2e31d096b2d341d to your computer and use it in GitHub Desktop.
Save deeperunderstanding/72f59140cefa28b0f2e31d096b2d341d to your computer and use it in GitHub Desktop.
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