this post was submitted on 10 Aug 2024
17 points (94.7% liked)
C Sharp
1526 readers
31 users here now
A community about the C# programming language
Getting started
Useful resources
- C# documentation
- C# Language Reference
- C# Programming Guide
- C# Coding Conventions
- .NET Framework Reference Source Code
IDEs and code editors
- Visual Studio (Windows/Mac)
- Rider (Windows/Mac/Linux)
- Visual Studio Code (Windows/Mac/Linux)
Tools
Rules
- Rule 1: Follow Lemmy rules
- Rule 2: Be excellent to each other, no hostility towards users for any reason
- Rule 3: No spam of tools/companies/advertisements
Related communities
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I'm not that familiar with newer c# code and only recently started with result pattern but tbh, I can't tell what is this code supposed to do. Does opt resolve to true or false in this case? Why do you want TestStringFail to always execute, and what should it return? Why is opt.None true when it was initialized with a valid string value, what does None even mean in this context?
The operator being applied to the ResultObject will always resolve to the Generic type that was specified as 'T in IResult. If the function is not successful the resolved value will be whatever value was supplied to the ResultObject constructor, the opt.None property will true and the opt.Some property will be false.
Check the edit on the post, I thought I had linked to the GitHub page but I guess the image overrides that.
Link: https://github.com/Andy3432344/SafeResults