Skip to content

Result(a, Nil) vs Option(a) #1265

Answered by lpil
J3RN asked this question in Questions & support
Sep 12, 2021 · 3 comments · 5 replies
Discussion options

You must be logged in to vote

Hello! Good question, thank you.

Result is to be used for operations that may not succeed, such as attempting to retrieve an entry from a data structure. Other languages use a mix of option and result for this scenario, but Gleam always uses result. This consistency means we have to do less converting between the two types and our special try syntax works with all fallible functions.

Later we will have better documentation for this, what we currently have is a bit basic while the core language and tooling is being worked on.

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@lpil
Comment options

@edongashi
Comment options

@lpil
Comment options

@edongashi
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by J3RN
Comment options

You must be logged in to vote
1 reply
@lpil
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants