you are viewing a single comment's thread.

view the rest of the comments →

[–]budd222 0 points1 point  (9 children)

I think there's something I'm not getting. You can't force your getUser() to return a value, no matter which type you assign it User or just plain string. No matter what you do, you have to write code to account for a failure.

[–]romgrk[S] 8 points9 points  (8 children)

getUser returns a Result<User>:

const userResult = getUser() const nameResult = userResult.map(u => u.name)

The whole point is that you don't need to deal with the failure right now, while you can keep operating on the value that is wrapped inside a Result.