Giter Club home page Giter Club logo

Comments (6)

megafinz avatar megafinz commented on June 16, 2024 2

Option<T>.ValueOrDefault seems legit.

from succinct.

megafinz avatar megafinz commented on June 16, 2024

What will value contain if hasValue is false?

from succinct.

DavidArno avatar DavidArno commented on June 16, 2024

default(T) would seem the obvious choice. I'd prefer the idea that its undefined, but out parameters have to be set, always, so that isn't an option.

If you think this inherently a bad idea though, I'm open to being convinced to drop it.

from succinct.

megafinz avatar megafinz commented on June 16, 2024

I don't think that's a bad idea, but I feel like it should be consistent with how Option<T>.Value behaves. Right now it's determined to throw an exception if HasValue == false, so maybe Option<T>.Value should return default(T) as well in this case.

from succinct.

DavidArno avatar DavidArno commented on June 16, 2024

If I changed Option<T>.Value to return default<T> when there's no value, then that would be a breaking change. So the choices are:

  1. Wait until v4 and introduce that breaking change (in reality there need not be a wait, v4 could be the next release, though this would mean creating a major version release though for a minor feature).
  2. Add a Option<T>.ValueOrDefault property that behaves this way and leave Option<T>.Value, as is.

from succinct.

DavidArno avatar DavidArno commented on June 16, 2024

Added to v3.1

from succinct.

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.