Code Monkey home page Code Monkey logo

Comments (5)

nlkl avatar nlkl commented on August 24, 2024

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.

janno-p avatar janno-p commented on August 24, 2024

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.

janno-p avatar janno-p commented on August 24, 2024

Waiting for .NET Core compatible NuGet packages to be released 😄

from optional.

nlkl avatar nlkl commented on August 24, 2024

@janno-p Just FYI, .NET Core support has just been released. Enjoy :)

from optional.

janno-p avatar janno-p commented on August 24, 2024

Great! I will.

from optional.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.