Skip to content

Instantly share code, notes, and snippets.

@deeperunderstanding
Last active November 23, 2019 19:33
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/8b0eb0a399e74ceac6a689ce2133b046 to your computer and use it in GitHub Desktop.
Save deeperunderstanding/8b0eb0a399e74ceac6a689ce2133b046 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<ResultSet<Pet>> = lines.map {
it.map(::toPet).asResultSet().map { pet -> pet.copy(name = pet.name.toUpperCase()) }
}
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