February 20, 2023

Error handling with Either in Java and Kotlin

TLDR Either is either Left or Right with values inside. Either is a union type. It's a concept that is language agnostic. It's right biased. Left is used to transport/represent errors. Right is used to transport/represent the successful data. =flatMap= and =map= are used to chain them together. bind is sugar over =flatMap= and =map= to make the code more sequential and easier to read. It short circuits if it gets a Left. Read more

Powered by Hugo & Kiss.