Skip to content

Instantly share code, notes, and snippets.

@deeperunderstanding
Created November 8, 2019 16:49
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/f6775d41051e54f1a1a6ccf1454a836c to your computer and use it in GitHub Desktop.
Save deeperunderstanding/f6775d41051e54f1a1a6ccf1454a836c to your computer and use it in GitHub Desktop.
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