How to use nested Result<> functions?
See original GitHub issueHow can I get the Result<> exception (if is there one?)
What I’m trying to do is this:
private Result<string> GetMyString()
{
...
}
public Result<string> MyMethod()
{
var strResult = GetMyString();
if (!strResult.IsSuccess)
return new Result<string>(strResult.GetException()); // <-- ???
// other things that can return a string or an exception
}
Am I missing something?
And if the only correct way is to use just the Match() method, how should I do?
because this doesn’t work
public Result<string> MyMethod()
{
var strResult = GetMyString();
return strResult.Match<Result<string>(
x=>
{
if(something)
return x;
else
return new Result<string>(new Exception("error message"));
},
ex => new Result<string>(ex)
);
}
Issue Analytics
- State:
- Created a year ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Use nested functions in a formula
Use nested functions in a formula · Click the cell in which you want to enter the formula. · To start the formula...
Read more >Nested Functions - MATLAB & Simulink
Nested functions can use variables that are not explicitly passed as input arguments. · In a parent function, you can create a handle...
Read more >How nested functions are used in Python?
A. A nested function refers to a function that is defined within another function's body. In programming languages that support this feature ( ......
Read more >Nested function
Lexically nested function definitions are a form of information hiding and are useful for dividing procedural tasks into subtasks which are only meaningful ......
Read more >How can I use the result of a nested function?
There are a couple problems here: 1) You aren't actually invoking returnFunction , just referencing the function in your return statement.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Check the reference for ‘alternative value monads’ and the a subsection on
Fin<A>You’re free to create your own type called
Final