Comments (5)
Hi Janno,
I will consider this. In general I am not a big fan of implicit conversions, and it does leave some questions to what the conversion behavior should be, e.g. should it return value.Some() or maybe even value.SomeNotNull() etc.
Usually I simply use the extension methods, e.g. var opt = true.Some();
, which leave very little syntactic overhead.
In my opinion, the only situation in which an implicit conversion "looks nicer", is when converting the return value (e.g. return true
vs return true.Some()
). However, this breaks the symmetry between .Some() and .None(), with very little benefit. As such, I do like explicitly choosing the conversion (.Some(), .None(), .SomeNotNull(), .SomeWhen(...), and so on).
Nevertheless, I will give it some thoughts. You are welcome to come up with more pros/cons.
/Nils
from optional.
Ok. This is all reasonable and those extension methods for conversion really help a lot. Since there are many possible interpretations for this implicit behavior (some might prefer null conversion to None, others might expect Some(null)), then it's hard to make a preference. And when one choice is made it might introduce some unexpected behaviors for end users.
Considering that, I agree, that explicit conversion is much safer way to go and this question is resolved for me.
from optional.
Waiting for .NET Core compatible NuGet packages to be released 😄
from optional.
@janno-p Just FYI, .NET Core support has just been released. Enjoy :)
from optional.
Great! I will.
from optional.
Related Issues (20)
- ValueOrFailure with specified exception. HOT 3
- Combine / Merge Options HOT 3
- IsNoneOr(predicate) HOT 2
- OptionTaskExtensions to work with ValueTask HOT 1
- Mark Option struct as readonly HOT 2
- Mark Map and FlatMap as Obsolete and rename to F# variants (not Scala) HOT 1
- Port nuget to .NET core HOT 2
- Richer Some / None models
- Nuget package automatically rolled back in VS2019 HOT 2
- Add exception based Filter HOT 1
- Option code optimizer HOT 1
- Should Optional implement IConvertable? HOT 2
- Match for async lambda doesn't return awaiter and isn't awaited HOT 3
- Should exists implicit operator between T and Option<T>? HOT 2
- Missing Licence in NuGet package
- Is there a reccomended alternative since this project has not been updated since 2018? HOT 9
- How can I convert an int? to Option.Some<uint>? HOT 1
- Map Exception and inner value HOT 2
- Migrate from Optional to the build-in c# Nullable Reference Types HOT 2
- README does not mention Optional.Collections
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from optional.